Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default choose range name according to cell

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default choose range name according to cell

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


"JSuarez" wrote:

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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Choose dat range for sumif formula Kane Excel Worksheet Functions 1 October 29th 09 04:47 AM
choose a cell in a range which has a text (there is only one) flying man Excel Discussion (Misc queries) 2 February 6th 09 03:43 PM
Choose From A Range FARAZ QURESHI Excel Discussion (Misc queries) 3 December 21st 08 09:49 PM
Choose From a Range Freshman Excel Worksheet Functions 3 July 29th 05 10:41 AM
How do I choose to only add the first 3 numbers in a range? Tom Ogilvy Excel Programming 0 September 15th 04 02:24 PM


All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"