+ Reply to Thread
Results 1 to 12 of 12

concatenate without empty cells

  1. #1
    Registered User
    Join Date
    05-11-2015
    Location
    Hasselt, Belgium
    MS-Off Ver
    2012
    Posts
    35

    concatenate without empty cells

    What is the vba formula to concatenate columns separated with "," only the cells where there is text inside. Do this untill the last row of text you can find.
    Can you make this starting for column 2 up to the last column with text?

    Thx

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: concatenate without empty cells

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    05-11-2015
    Location
    Hasselt, Belgium
    MS-Off Ver
    2012
    Posts
    35

    Re: concatenate without empty cells

    excel.xlsb

    I hope this worked.
    This is simplified what I want. I have a lot more data in different row format. So please do select untill last row

    The after worksheet as you see is at row 10 (row above the content) concatenate all with "," , no blank rows.

    Thx

  4. #4
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: concatenate without empty cells

    Quote Originally Posted by BROEA View Post
    What is the vba formula to concatenate columns separated with "," only the cells where there is text inside. Do this untill the last row of text you can find.
    Can you make this starting for column 2 up to the last column with text?

    Thx
    Hi Broea,

    . It is not clear wot exactly you want. Try to give a screenshot which we can copy to a spreadsheet. That makes it easier for us to understand, and helps for anyone following the Thread. ( Notes for doing that in my signature ). Alternatively upload ( attach ) a workbook as clearly explained by Sixthsense – take particular note about the BEFORE and AFTER - that always describes exactly what Yous want the best. The AFTER should look exactly as Yous want after the macro is run based on the sample data Yous give in the BEFORE.

    . Is this at least getting close to wot yous wanting?:

    . Say you have this:

    Using Excel 2007
    -
    A
    B
    C
    D
    1
    Tom1 Dick1 Arries1
    2
    Tom2 Dick2 Arries2
    3
    Tom3 Dick3 Arries3
    4
    Tom4 Dick4 Arries4
    5
    Tom5 Dick5 Arries5
    6
    Tom6 Arries6
    7
    Tom7 Dick7 Arries7
    BROEA

    ……
    Would this be maybe what you want it to look like after running any macro

    Using Excel 2007
    -
    A
    B
    C
    D
    E
    1
    Tom1 Dick1 Arries1 Tom1 , Dick1 , Arries1
    2
    Tom2 Dick2 Arries2 Tom2 , Dick2 , Arries2
    3
    Tom3 Dick3 Arries3 Tom3 , Dick3 , Arries3
    4
    Tom4 Dick4 Arries4 Tom4 , Dick4 , Arries4
    5
    Tom5 Dick5 Arries5 Tom5 , Dick5 , Arries5
    6
    Tom6 Arries6 Tom6 Arries6
    7
    Tom7 Dick7 Arries7 Tom7 , Dick7 , Arries7
    BROEA

    … if so, here is the code:

    Please Login or Register  to view this content.



    Alan
    '_- Google first, like this _ site:ExcelForum.com Gamut
    Use Code Tags: Highlight code; click on the # icon above,
    Post screenshots COPYABLE to a Spredsheet; NOT IMAGES PLEASE
    http://www.excelforum.com/the-water-...ml#post4109080
    https://app.box.com/s/gjpa8mk8ko4vkwcke3ig2w8z2wkfvrtv
    http://excelmatters.com/excel-forums/ ( Scrolll down to bottom )

  5. #5
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: concatenate without empty cells

    Quote Originally Posted by BROEA View Post
    Attachment 394166

    I hope this worked.
    This is simplified what I want. I have a lot more data in different row format. So please do select untill last row

    The after worksheet as you see is at row 10 (row above the content) concatenate all with "," , no blank rows.

    Thx
    .... Ahh... I sent my last post, before i saw your reply with an attachment...
    .. I will take a look at that now...

    Alan

  6. #6
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: concatenate without empty cells

    Duplicate post

  7. #7
    Registered User
    Join Date
    05-11-2015
    Location
    Hasselt, Belgium
    MS-Off Ver
    2012
    Posts
    35

    Re: concatenate without empty cells

    hi, thx for the post. This is exactly what I mean, but for columns instead of rows.

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: concatenate without empty cells

    maybe so
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-11-2015
    Location
    Hasselt, Belgium
    MS-Off Ver
    2012
    Posts
    35

    Re: concatenate without empty cells

    I adjust the macro to look untill the last column
    Sub ttt()
    Dim i&
    Dim lastcol As Long
    lastcol = Range("A1").SpecialCells(xlCellTypeLastCell).Column

    For i = 2 To lastcol
    With Range(Cells(132, i), Cells(Rows.Count, i).End(xlUp))
    Cells(131, i).Value = Replace(Join(Filter(Split("~" & Join(Application.Transpose(.Value), _
    "~,~") & "~", ","), "~~", False), ","), "~", "")
    End With
    Next
    End Sub

    This does the trick what I want, but he gives an error on your command, I think because my specification of lastcolumn is not correct.
    Can you add to the this when a column is blank inbetween to add a " " so the text doesn't go through the next cell. Also in the cell next to the lastcell (in this case E10)

    thx

  10. #10
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: concatenate without empty cells

    please use code tags around your code

    and try it
    Please Login or Register  to view this content.

  11. #11
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: concatenate without empty cells

    ……….. And ‘ere comes the part-time amateur with his attempt….

    BEFORE:

    Using Excel 2007
    -
    B
    C
    D
    11
    1
    12
    1
    13
    2
    2
    14
    2
    15
    3
    16
    4
    4
    17
    5
    5
    BROEA

    AFTER:

    Using Excel 2007
    -
    B
    C
    D
    10
    1,2,2,4,5 2,3,4, 1,5
    11
    1
    BROEA

    …….
    …..

    Code:

    Please Login or Register  to view this content.

  12. #12
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: concatenate without empty cells

    … maybe this is bit quicker for large files…

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Forumulas & functions:Concatenate with wrap text and skip empty cells
    By Linja13 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 07-14-2014, 11:19 AM
  2. [SOLVED] Concatenate IF cell is not empty
    By GMSuppliesltd in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-05-2013, 01:58 AM
  3. [SOLVED] CONCATENATE with Auto Numbering and Eliminate the Empty Value cell(Cells contains Formula)
    By KSQUARE2K6 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-06-2013, 01:21 PM
  4. Macro to concatenate cells in a range that skips empty columns
    By _lm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2011, 03:53 PM
  5. Replies: 2
    Last Post: 04-12-2010, 12:35 PM

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