+ Reply to Thread
Results 1 to 4 of 4

string concatenate

  1. #1
    DorisM
    Guest

    string concatenate

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

  2. #2
    STEVE BELL
    Guest

    Re: 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" <DorisM@discussions.microsoft.com> wrote in message
    news:04246176-0582-4A95-BCCC-5BF77982B634@microsoft.com...
    > 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.
    > ????




  3. #3
    DorisM
    Guest

    Re: 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" <DorisM@discussions.microsoft.com> wrote in message
    > news:04246176-0582-4A95-BCCC-5BF77982B634@microsoft.com...
    > > 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.
    > > ????

    >
    >
    >


  4. #4
    STEVE BELL
    Guest

    Re: 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" <DorisM@discussions.microsoft.com> wrote in message
    news:7174FCCB-9A22-46EA-917D-D94447950E9C@microsoft.com...
    > 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" <DorisM@discussions.microsoft.com> wrote in message
    >> news:04246176-0582-4A95-BCCC-5BF77982B634@microsoft.com...
    >> > 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.
    >> > ????

    >>
    >>
    >>




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1