View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Setting variable names in code

Hi
I would use an array variable for this. have a look for array variables
in the vBA help
e.g.
dim xp(10)
xp(1)="hello"
xp(2)="world"
msgbox xp(1) & " " & xp(2)



--
Regards
Frank Kabel
Frankfurt, Germany


Newbie wrote:
Hi,

I would like to know how to set a variable name in code.
I need a number of variable, eg xp01, xp03, xp06 etc where the last
two digits are dependent on cell values.

At the moment I am typing them into the code manually i.e. xp01 =
"whatever": xp03 = 4 etc and listing all the xp**.
So if someone could tell me how to build the variable name within
VBA, I could then loop the the sheet to set the variable values.

TIA