Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do you create a variable variable? Consider this code
dim x as strin x = "Whatever the character 'x' may be different (for later use) and needs to be dynamically defined in code from a cell value TIA |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
For what purpose? In most cases you wont need to do that.
It is possible. I know you can dynamically alter the code in a module using VBComponent object. I have some examples on my website - but as I said, I think it's unnecessary. Just tell us the reason behind it. Perhaps there's a better way. -- Rob van Gelder - http://www.vangelder.co.nz/excel "Lawlera" wrote in message ... How do you create a variable variable? Consider this code: dim x as string x = "Whatever" the character 'x' may be different (for later use) and needs to be dynamically defined in code from a cell value. TIA |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Rob
Just for the sake of it if I'm honest. The idea was born out of need to loop through 100 or so sheets and returning a value for each one after a series of calculations, hence the variable could have a letter and the sheets number added |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
for this use an array variable. e.g. try something like the following: Sub get_sheetnames() Dim sname() Dim wks_index Dim wks_count wks_count = ActiveWorkbook.Worksheets.Count ReDim sname(1 To wks_count) For wks_index = 1 To wks_count sname(wks_index) = ActiveWorkbook.Worksheets (wks_index).Name Next For wks_index = 1 To wks_count MsgBox sname(wks_index) Next End Sub -----Original Message----- Hi Rob, Just for the sake of it if I'm honest. The idea was born out of need to loop through 100 or so sheets and returning a value for each one after a series of calculations, hence the variable could have a letter and the sheets number added. . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It sounds like you want a dynamic array.
Sub test() Dim arr() Dim i As Long ReDim arr(100) For i = 1 To 100 arr(i) = i * 10 Next For i = 1 To 100 Debug.Print arr(i) Next End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Lawlera" wrote in message ... Hi Rob, Just for the sake of it if I'm honest. The idea was born out of need to loop through 100 or so sheets and returning a value for each one after a series of calculations, hence the variable could have a letter and the sheets number added. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lookup Question with multiple dynamic variables | Excel Worksheet Functions | |||
Add up a Dynamic Range with 2 Variables | Excel Worksheet Functions | |||
Add up a Dynamic Range with 2 Variables | Excel Worksheet Functions | |||
Add up a Dynamic Range with 2 Variables | Excel Worksheet Functions | |||
dynamic variables | Excel Programming |