dellehurley
Board Regular
- Joined
- Sep 26, 2009
- Messages
- 171
- Office Version
- 365
- Platform
- Windows
Hi
I was wondering if it is possible to create a variable number of variables. If I count the number of times something happens that I can create a variable that many times. ie, count =10 and variable the named variable in this case y is created 10 times = y1,y2,y3,y4 etc up to 10, or a 1000 or as many times as needed. Something like the control function.
I hope this makes some sort of sense.
Dannielle
I was wondering if it is possible to create a variable number of variables. If I count the number of times something happens that I can create a variable that many times. ie, count =10 and variable the named variable in this case y is created 10 times = y1,y2,y3,y4 etc up to 10, or a 1000 or as many times as needed. Something like the control function.
VBA Code:
Sub VariableVariables()
Dim x As Integer
Dim Cnt As Integer
Dim y As String
Cnt = Application.WorksheetFunction.CountIf(Ws.Range("A:A"), x)
Do Until cnt = 0
y& Cnt = something
'create variable that looks something like this... y1, y2, y3 etc
'do something
Cnt = Cnt - 1
Loop
End Sub
I hope this makes some sort of sense.
Dannielle