PC Review


Reply
Thread Tools Rate Thread

choose range name according to cell

 
 
=?Utf-8?B?SlN1YXJleg==?=
Guest
Posts: n/a
 
      11th Jul 2007
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 With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      11th Jul 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
choose a cell in a range which has a text (there is only one) flying man Microsoft Excel Misc 2 6th Feb 2009 03:43 PM
Choose From A Range FARAZ QURESHI Microsoft Excel Misc 3 21st Dec 2008 09:49 PM
Choose From a Range =?Utf-8?B?RnJlc2htYW4=?= Microsoft Excel Worksheet Functions 3 29th Jul 2005 10:41 AM
Re: How do I choose to only add the first 3 numbers in a range? Tom Ogilvy Microsoft Excel Programming 0 15th Sep 2004 02:24 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Microsoft Excel Programming 12 10th Jun 2004 04:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:27 AM.