Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RNM RNM is offline
external usenet poster
 
Posts: 1
Default Dynamic variable Reference

In VBA, how does one make a reference to a dynamic veraiable?

If I have named ranges "ABC1" thru "ABC9".
User enters "5" so I want to get the value of range "ABC5".
Without using Case statements.

Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Dynamic variable Reference


RangeName = "ABC" & Format$(n)

where n contains the number the user entered.

On Sat, 7 Aug 2004 20:15:48 -0500, RNM
wrote:

In VBA, how does one make a reference to a dynamic veraiable?

If I have named ranges "ABC1" thru "ABC9".
User enters "5" so I want to get the value of range "ABC5".
Without using Case statements.

Thanks,


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic variable Reference

How about if I need to reference a variable, not a range.

user enters a number(1-9).
I need to put a value in variable either "a1", "a2",... or "a9"
without using case statement

Thank you

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Dynamic variable Reference

RNM wrote:

How about if I need to reference a variable, not a range.

user enters a number(1-9).
I need to put a value in variable either "a1", "a2",... or "a9"
without using case statement

Thank you,


---
Message posted from http://www.ExcelForum.com/


Use an array.

Dim a(1 To 9) As Integer ' Or whatever other variable type
This single statement gives you 9 variables: a(1), a(2), a(3), ...
until a(9).

And then you use a(n) where n is the number the user entered.

--
Amedee Van Gasse using XanaNews 1.16.3.1
If it has an "X" in the name, it must be Linux?
Please don't thank me in advance. Thank me afterwards if it works or
hit me in the face if it doesn't. ;-)

I found 2 small shortcomings on www.excelforum.com:
1. You do *not* have to pay for access to news:msnews.microsoft.com
2. A *real* newsreader (not Outlook Express) is actually very easy to
use. See www.newsreaders.com for more info.
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
Need to replace one dynamic variable with another dynamic variable djreason Excel Worksheet Functions 8 September 11th 09 01:57 AM
How do i set up a 3d reference where one cell reference is dynamic SmilingSteve Excel Discussion (Misc queries) 15 March 14th 08 05:05 AM
Dynamic Variable Name Jake[_9_] Excel Programming 2 June 1st 04 06:19 PM
Refreshing a dynamic range variable Gromit Excel Programming 3 December 3rd 03 08:28 PM
Create dynamic variable names? J Kruger Excel Programming 4 November 27th 03 09:41 PM


All times are GMT +1. The time now is 07:27 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"