variable variables

Q

QB

Hi am trying to write some vba code that will adapt with my very variable
data. As such, I am using arrays, etc. The basics work, but I have now hit
a little bump in the road that I hope someoe can show me how to get around.

Basically, for each item in the array, I need to store certain value into
variable. I was trying to build these variable using the array item number,
but don't seem to be able to get the code right. For instance,

For i = LBound(Array1) to UBound(Array1)
'I perform a filter on my data here (Removed to simplify my code)
"Sub" & Array1(i) = Range("SubTotal").Value
Next i

Basically I want to create a series of sequential variable holding the values:
Sub1 =
Sub2 =
Sub3 =

How can this be done?

QB
 
J

joel

Sub test()

Dim Mytotals() As Variant

ReDim Mytotals(LBound(Array1) To UBound(Array1))

For i = LBound(Array1) To UBound(Array1)
Mytotals(i) = Range("SubTotal").Value
Next i

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top