LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Copy named range based on variable

Is it possible to copy a named range based on a variable?

I have a number of named ranges which I need to copy based on the
results of a cell value.

My whole routine is nearly 500 lines of code, so I've only included the
relevant bits in this message. For example, I have the following lines at
the start of my routine:

With Worksheets("Lookup")
Set MTS215Vision30 = .Range("MTS2.16Vision30")
Set MTS216Vision30 = .Range("MTS2.16Vision30")
End With

and want to copy one of these based on the value of cell which could
currently contain 2.15 or 2.16.

This line:
sMTSVer = "MTS" & Worksheets("Input").Range("T3") * 100 & "Vision30"
makes sMTSVer = MTS216Vision30

This works:
MTS216Vision30.Copy .Range("A5")
But this doesn't:
sMTSVer.Copy .Range("A5")

I know I could use something like .....
With Worksheets("Input")
If .Range("T3")=2.15 then
MTS215Vision30.Copy .Range("A5")
Elseif .Range("T3")=2.16 then
MTS216Vision30.Copy .Range("A5")
End If
End WIth
...... but in time there will be 2.17, 2.18 etc and I am hoping to "future
proof" the code so that I only need to create the named ranges and add a
"Set" line rather than having to add more If conditions, as the Vision30
example is only one of a number of similar situations.

Any ideas? I need this to work on any machine with a "default" Excel 2000
installation (ie not an add-in).

--
Ian
--


 
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
Copy&Paste variable range based on cell value Thomas Excel Programming 0 July 27th 07 06:40 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
Finding a named range based on cell value and copy/paste to same sheet? Simon Lloyd[_715_] Excel Programming 1 May 11th 06 11:25 PM
referencing a named range using a variable mark kubicki Excel Programming 0 May 7th 04 12:15 AM
Can A Named Range Be A Variable? Minitman[_2_] Excel Programming 7 February 25th 04 11:41 PM


All times are GMT +1. The time now is 11:10 AM.

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"