View Full Version : Solved: Forming a variable name
jwise
04-13-2007, 07:48 AM
I need to form names like A01, A02, ... . I would also like to handle A001, A002, ... as well. Ultimately, these will be used as part of a filename. The numbers being the distinguishing part. I do not want "A1" since it is two characters, I do want "A01", etc.
Ideas?
makako
04-13-2007, 08:00 AM
i not sure i follow but it sound u need to use the format function and generate the variables, for instance:
for i = 1 to lenght
string1 = "A" & Format(i,"00")
next
mvidas
04-13-2007, 08:03 AM
..what?
What are you trying to do? Do you have a number (ie 1, 2, 3, etc) that you want to create a string like A01, A02, A03?
Assuming your variable is named "iNum", use the Format function:Sub jwiseExample()
Dim iNum As Long
iNum = 3
MsgBox Format(iNum, """A""00")
'or
MsgBox "A" & Format(iNum, "00")
End SubOtherwise you may have to explain a little more what you're doing (I could just be a little tired this morning).
Matt
Sounds like you are wanting to create variable names on the fly. If so, not possible.
jwise
04-13-2007, 08:49 AM
I did not know about the "format" function.
I am trying to form filenames and/or worksheet names, and NOT variable names. I apologize for ambiguous wording in my original post.
Thanks again.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.