Solved

Selection.Replace does not work

Posted on 2011-03-24
7
426 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
  • 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now