+ Reply to Thread
Results 1 to 5 of 5

Code: Concatenate

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-09-2008
    Location
    Washington State
    MS-Off Ver
    2007
    Posts
    164

    Code: Concatenate

    I have three columns (9, 10, & 11); text, currency, and text and I am trying to move them from seperate columns on Sheet2 to one column with forward slashes "/" between them on Sheet3. The attached code does this, however I lose the dollar sign and commas. I need help combining them AND maintaining the dollar sign and commas.

    ws3.Cells(NR, 9) = (ws2.Cells(a, 9).Value & "/" & ws2.Cells(a, 10).Value & "/" & ws2.Cells(a, 11).Value)
    Thanks.
    Last edited by abuchan; 01-11-2010 at 11:14 AM. Reason: solved

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264

    re: Code: Concatenate

    You could just use the Text property of the currency (?) column to display the value as it appears in the cell:

    ws3.Cells(NR, 9) = (ws2.Cells(a, 9).Value & "/" & ws2.Cells(a, 10).Text & "/" & ws2.Cells(a, 11).Value)
    Richard
    Richard Schollar
    Microsoft MVP - Excel

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    re: Code: Concatenate

    This seems to work
        ws3.Cells(NR, 9) = (ws2.Cells(a, 9).Value & "/" & Format(ws2.Cells(a, 10).Value, "$#,##0.00") & "/" & ws2.Cells(a, 11).Value)
    Dont know where the commas come in to it

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: Code: Concatenate

    Not sure why you need code to do this,try
    ws3.Cells(NR, 9) = (ws2.Cells(a, 9).Value & "/" & Format(ws2.Cells(a, 10).Value, "currency") & "/" _
        & ws2.Cells(a, 11).Value)
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    re: Code: Concatenate

    In case cell is not formatted.

+ 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