• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

Selection.Replace does not work

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
decisionfocus
Asked:
decisionfocus
  • 3
  • 2
  • 2
2 Solutions
 
Saqib Husain, SyedEngineerCommented:
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
 
decisionfocusAuthor Commented:
so - why does the cell content in the sheet still say SAND and FALSK when it should say TRUE and FALSE?
0
 
FernandoFernandesCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Saqib Husain, SyedEngineerCommented:
In the file provided in the question I cannot find any falsk or sand. Which cells are they in?
0
 
decisionfocusAuthor Commented:
.... 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
 
Saqib Husain, SyedEngineerCommented:
No bother as long as the points are coming in. Thanks for the grade
0
 
FernandoFernandesCommented:
lol... thanks man!
0

Featured Post

Industry Leaders: 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!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now