Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Selection.Replace does not work

Posted on 2011-03-24
7
Medium Priority
?
465 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
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.

 
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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

609 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