Solved

Selection.Replace does not work

Posted on 2011-03-24
7
447 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 250 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 250 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
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!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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 will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

718 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