![]() |
string concatenate
New to VBA so I'm not sure if this is possible. In a program, Im trying to
concatenate string variables with comma after each variable, but the number of occurrences of string variable can be different from time to time. ???? |
string concatenate
This code will check column A,
rows 1 to 25 and make a string see if this helps... ================================= Sub StringCreat() Dim rw As Long, str As String For rw = 1 To 25 If Len(Cells(rw, 1)) 0 Then If Len(str) 0 Then str = str & ", " & Cells(rw, 1).Text Else str = Cells(rw, 1).Text End If End If Next MsgBox str End Sub ==================================== -- steveB Remove "AYN" from email to respond "DorisM" wrote in message ... New to VBA so I'm not sure if this is possible. In a program, I'm trying to concatenate string variables with comma after each variable, but the number of occurrences of string variable can be different from time to time. ???? |
string concatenate
Hi Steve;
Thank you for your help. I modify the code to what I needed to do in my program and it works. DorisM "STEVE BELL" wrote: This code will check column A, rows 1 to 25 and make a string see if this helps... ================================= Sub StringCreat() Dim rw As Long, str As String For rw = 1 To 25 If Len(Cells(rw, 1)) 0 Then If Len(str) 0 Then str = str & ", " & Cells(rw, 1).Text Else str = Cells(rw, 1).Text End If End If Next MsgBox str End Sub ==================================== -- steveB Remove "AYN" from email to respond "DorisM" wrote in message ... New to VBA so I'm not sure if this is possible. In a program, I'm trying to concatenate string variables with comma after each variable, but the number of occurrences of string variable can be different from time to time. ???? |
string concatenate
Doris,
Am happy to hear that you got it to work! You are very Welcome! keep on Exceling... -- steveB Remove "AYN" from email to respond "DorisM" wrote in message ... Hi Steve; Thank you for your help. I modify the code to what I needed to do in my program and it works. DorisM "STEVE BELL" wrote: This code will check column A, rows 1 to 25 and make a string see if this helps... ================================= Sub StringCreat() Dim rw As Long, str As String For rw = 1 To 25 If Len(Cells(rw, 1)) 0 Then If Len(str) 0 Then str = str & ", " & Cells(rw, 1).Text Else str = Cells(rw, 1).Text End If End If Next MsgBox str End Sub ==================================== -- steveB Remove "AYN" from email to respond "DorisM" wrote in message ... New to VBA so I'm not sure if this is possible. In a program, I'm trying to concatenate string variables with comma after each variable, but the number of occurrences of string variable can be different from time to time. ???? |
All times are GMT +1. The time now is 10:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com