?
Solved

Selection.Replace does not work

Posted on 2011-03-24
7
Medium Priority
?
456 Views
Last Modified: 2012-05-11
Hi,

I recorded a macro to replace the contents of a range of cells with other contents. It works fine when i record the macro - i.e. choose Replace, enter the values in the pop-up box - but when executing the recorded code nothing is replaced.

The recorded code should replace cell contents in the sheet "Focal Point import" in the attached file.

Range("A1:HE2").Select
    Selection.Replace What:="FALSK", Replacement:="FALSE", LookAt:=xlWhole, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Selection.Replace What:="SAND", Replacement:="TRUE", LookAt:=xlWhole, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("A1").Select

Br Jonas
Risikoscore--20110317-vers.1.1-F.xls
0
Comment
Question by:decisionfocus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 1000 total points
ID: 35206366
In the given file the values are already replaced. There is nothing to replace.

To check the working you can now interchange falsk and false and run the macro.

Saqib
0
 

Author Comment

by:decisionfocus
ID: 35206410
so - why does the cell content in the sheet still say SAND and FALSK when it should say TRUE and FALSE?
0
 
LVL 6

Assisted Solution

by:FernandoFernandes
FernandoFernandes earned 1000 total points
ID: 35206738
Range("A1:HE2").Select
    Selection.Replace What:="FALSK", Replacement:="FALSE", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Selection.Replace What:="SAND", Replacement:="TRUE", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("A1").Select

know that only the cells within the range A1:HE2 will be replaced, not any other cell of the sheet.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35206767
In the file provided in the question I cannot find any falsk or sand. Which cells are they in?
0
 

Author Comment

by:decisionfocus
ID: 35207597
.... it's never nice to realise that you're an absolute moron.... there was no problem to begin with i was just looking at it wrongly.

I'll accept all your solutions and split the points. Sorry for the bother.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35208098
No bother as long as the points are coming in. Thanks for the grade
0
 
LVL 6

Expert Comment

by:FernandoFernandes
ID: 35208161
lol... thanks man!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question