Consulting

Results 1 to 8 of 8

Thread: Concatenate Two Cells in a third cell

  1. #1
    VBAX Regular
    Joined
    Mar 2017
    Posts
    55
    Location

    Concatenate Two Cells in a third cell

    Hi,

    This seems like a simple procedure but just cannot get this to work right. I would like to concatenate two fixed cells into the third cell.

    For example:
    Cell A1=Hello
    Cell A2=World
    Cell A3= Hello World

    Thank you.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    =A1 & " " & A2
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Mar 2017
    Posts
    55
    Location
    Thank you mdmackillop. But how would I do this in VBA? This would be part of a Macro.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    Range("A3").Value = Range("A1").Value & Range("A2").Value
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    ... and with a space between
    Range("A3").Value = Range("A1").Value & " " & Range("A2").Value
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    VBAX Regular
    Joined
    Mar 2017
    Posts
    55
    Location
    thanks Paul. I have it in a file with multiple works sheets. These cells are located on shee1. I'm putting Sheets("Sheet1") in front of your code but cant seem to make i work. Would this be the right approach?

  7. #7
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    Expanding on Mac's ...

    Without explicitly specifying a worksheet, as is it will use whatever the ActiveSheet is

    This is specific to Sheet1

    Worksheets("Sheet1").Range("A3").Value = Worksheets("Sheet1").Range("A1").Value & " " & Worksheets("Sheet1").Range("A2").Value

    or to save a little typing

    With Worksheets("Sheet1")
        .Range("A3").Value = .Range("A1").Value & " " & .Range("A2").Value
    End With
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  8. #8
    VBAX Regular
    Joined
    Mar 2017
    Posts
    55
    Location
    Thank you Paul!

Tags for this Thread

Posting Permissions

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