ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting variable names in code (https://www.excelbanter.com/excel-programming/298946-re-setting-variable-names-code.html)

Frank Kabel

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




All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com