+ Reply to Thread
Results 1 to 4 of 4

Concatenate function in vba

  1. #1
    camerons
    Guest

    Concatenate function in vba

    I am trying to do the following:

    Sub Sample()
    For a = 1 To 100
    r = concatenate(Cells(a, 1), Cells(a, 2))
    If r = "Mr.Jones" Then
    Cells(a, 3) = ""
    End If
    Next a
    End Sub

    There is more to it, but I can't seem to use the concatenate function.
    "Left", "Right" are ok, but not this one it seems. What am I missing?

    Thank you
    Chris Cameron
    [email protected]



  2. #2
    JMB
    Guest

    RE: Concatenate function in vba

    you have to use the "&"

    = Cells(a, 1) & Cells(a, 2)


    "camerons" wrote:

    > I am trying to do the following:
    >
    > Sub Sample()
    > For a = 1 To 100
    > r = concatenate(Cells(a, 1), Cells(a, 2))
    > If r = "Mr.Jones" Then
    > Cells(a, 3) = ""
    > End If
    > Next a
    > End Sub
    >
    > There is more to it, but I can't seem to use the concatenate function.
    > "Left", "Right" are ok, but not this one it seems. What am I missing?
    >
    > Thank you
    > Chris Cameron
    > [email protected]
    >
    >
    >


  3. #3
    JE McGimpsey
    Guest

    Re: Concatenate function in vba

    One way:

    Dim a As Long
    For a = 1 To 100
    If Cells(a, 1).Text & Cells(a, 2).Text = "Mr.Jones" Then _
    Cells(a, 3).ClearContents
    Next a


    In article <[email protected]>,
    "camerons" <[email protected]> wrote:

    > I am trying to do the following:
    >
    > Sub Sample()
    > For a = 1 To 100
    > r = concatenate(Cells(a, 1), Cells(a, 2))
    > If r = "Mr.Jones" Then
    > Cells(a, 3) = ""
    > End If
    > Next a
    > End Sub
    >
    > There is more to it, but I can't seem to use the concatenate function.
    > "Left", "Right" are ok, but not this one it seems. What am I missing?
    >
    > Thank you
    > Chris Cameron
    > [email protected]


  4. #4
    camerons
    Guest

    Re: Concatenate function in vba

    Thanks, I've got it working now.
    What would you suggest for learning correct syntax for VBA?





+ 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