Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Is there a better way to concatenate strings in excel vba. The below code is not giving me the desired results. Could you please tell what could be the reason? For i = 1 To nmodules Sname = "START_" & Str(i) MsgBox "The String is " & Sname Next i The result is START_<space1 START_<space2 .....and so on Excel is placing a space between the arguments. The desired results is START_1, START_2 etc. shi |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use
Sname = Sname & "START_" & Str(i) & ", " -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "shishi" wrote in message oups.com... Hi, Is there a better way to concatenate strings in excel vba. The below code is not giving me the desired results. Could you please tell what could be the reason? For i = 1 To nmodules Sname = "START_" & Str(i) MsgBox "The String is " & Sname Next i The result is START_<space1 START_<space2 .....and so on Excel is placing a space between the arguments. The desired results is START_1, START_2 etc. shi |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mr. Pearson,
I tried using the above solution, still the excel is placing a space between START_ and 1. So I get results like START_ 1. Any more ideas?? Thanks, Shi |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Shi,
I think Chip may have gone to dinner... The "Str" function automatically adds a space to contain the sign of the number. The "Cstr" function would work for you, however it is not required. The "&" operator will convert the i variable to a string so, assuming that Sname is a String... Sname = "START_" & i is all you need. Jim Cone San Francisco, USA "shishi" wrote in message oups.com... Hi, Is there a better way to concatenate strings in excel vba. The below code is not giving me the desired results. Could you please tell what could be the reason? For i = 1 To nmodules Sname = "START_" & Str(i) MsgBox "The String is " & Sname Next i The result is START_<space1 START_<space2 .....and so on Excel is placing a space between the arguments. The desired results is START_1, START_2 etc. shi |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need Help With String Concatenation | Excel Worksheet Functions | |||
Need Help With String Concatenation | Excel Worksheet Functions | |||
Bold in string concatenation | Excel Discussion (Misc queries) | |||
How do I put each member of string concatenation in its own line? | Excel Worksheet Functions | |||
string concatenation | Excel Programming |