Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a variable name within a for loop

Status
Not open for further replies.

gareth001

Technical User
Feb 4, 2003
43
GB
Hi,

I've created 6 variables, TargetNo1 through to TargetNo6. When I run the For loop I need it to use the counter in the loop and concatenate it with "Target" so I can then run an If statement on the values held TargetNo1 to TargetNo6.

The VBA I'm using is as follows:

Code:
  For intLabel = 1 To 6
    Target = ("TargetNo" & intLabel)
    If Target = 0 Then
        intLabel = intLabel + 1

But Target holds the text string of "TargetNo1" not the value of the variable.

Thanks for you help in advance

Gareth
 
Why not using an array ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top