PDA

View Full Version : Dynamically creating variables...possible?



title_bu
07-28-2010, 06:02 AM
All,

I was wondering if there was a way to dynamically create variables based inconsistent range selections? For these purposes I just fixed the column positions, but you understand that this might just be field names of various tables (or whatever) This is a trimmed down version of what Im trying to do and, like I said, I have no idea if its possible...

Sub dynamicVarCreation()

Dim i As Integer
Dim left_Selection_Col As Integer
Dim right_Selection_Col As Integer

left_Selection_Col = 1
right_Selection_Col = 7

i = left_Selection_Col

For i = left_Selection_Col To right_Selection_Col - left_Selection_Col + 1

dim "Var" & i as Variant

Next i

End Sub

Bob Phillips
07-28-2010, 06:05 AM
No, you can't do that. That is what arrays are for.