Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding a counter to a variable name
I will be collecting values from multiple sheets.
How do I create a variable name with a counter attached to it, and how do I declare that variable. For example, I want variable names to be "DkType1", "DkType2", etc. I don't know how many "DkType"s I will have. Thanks!!! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding a counter to a variable name
You probably want an array...
Sub stuff() Dim DKType() As Variant Dim lng As Long ReDim DKType(lng) DKType(lng) = Range("A1").Value lng = lng + 1 ReDim Preserve DKType(lng) DKType(lng) = Range("A2").Value lng = lng + 1 ReDim Preserve DKType(lng) DKType(lng) = Range("A3").Value For lng = LBound(DKType) To UBound(DKType) MsgBox DKType(lng) Next lng Range("C1:C3").Value = Application.Transpose(DKType) 'write the array End Sub -- HTH... Jim Thomlinson "Rich" wrote: I will be collecting values from multiple sheets. How do I create a variable name with a counter attached to it, and how do I declare that variable. For example, I want variable names to be "DkType1", "DkType2", etc. I don't know how many "DkType"s I will have. Thanks!!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding counter to new worksheet | Excel Programming | |||
Counter variable and a multiplier | Excel Discussion (Misc queries) | |||
Adding a counter to ranges | Excel Programming | |||
Counter variable in For Loop | Excel Programming | |||
variable counter/total | Excel Programming |