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!!!
|