choose range name according to cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I need to choose among different ranges depending on the value of one cell.
for example, if the value of cell A1 is "IT", I need to subtitute all "GE"
text in a range cells with "IT".

Here is what I have, but it works for only one case. I need for 21 different
choices in cell A1.



Range("D6:E111,H6:I111,L6:M111,M113,L113,I113,H113,E113,D113,M224,L224,I224,H224,E224,D224").Select

Selection.Replace What:="GE", Replacement:="IT", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Is there any kind of loop for this?
 
If your Range of cells to be replace remain constant and only the value of
Range("A1") changes, Then you could use a reference to the value of
Range("A1") like this:

x = Range("A1").Value

Selection.Replace What:="GE", Replacement:=x, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top