string concatenate

G

Guest

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. ????
 
S

STEVE BELL

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
====================================
 
G

Guest

Hi Steve;

Thank you for your help. I modify the code to what I needed to do in my
program and it works.

DorisM
 
S

STEVE BELL

Doris,

Am happy to hear that you got it to work! You are very Welcome!

keep on Exceling...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top