• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

use for loop variable in other variables name

kornbrot

New Member
hello again.

i am trying to build a loop that uses the counting numer as part of a variable name within the loop. something like this:


for i = 1 to VariableA

dim VariableB"number stored in i" as double

VariableB"number stored in i" = applications.inputbox("insert thickness", "data input x + "number stored in i",,,,,,1)


i = i + 1

next i


so after the loop i want a set of variables called VariableB1, VariableB2, ...


is this possible?

regards,

kornbrot
 
hi,

it might be, but i'm trying to build the complete worksheet from scratch only from the input values entered in the inpuboxes...


kornbrot
 
Hi ,


Would the following be useful ?


Name several ranges VariableB1 , VariableB2 , ...


Use the following code to put values into those ranges :


Public Sub Populate_Vars()

For i = 1 To VariableA

varA = "variableB" & i

Range(varA).Value = Application.InputBox("insert thickness", "data input x + number stored in i", , , , , , 1)

Next

End Sub


Narayan
 
Back
Top