+ Reply to Thread
Results 1 to 6 of 6

Thread: =MultiCat removing commas from a string

  1. #1
    Registered User
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    22

    =MultiCat removing commas from a string

    I D/L this script for an excel concatenate problem I had, and it works exactly the way it says it should. It's function is to concatenate a list of cells (the =concatenate in Excel cannot do this for a range, only for identified cell refs, I have a column of over 300)

    My problem is that many cells in my lists are empty and my output from =MULTICAT has strings of commas (the delimiters I chose) where the empty cells are, so a result will look like this :

    ,,,,,,,,,word1,,,,word2,,,word3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,word4,,,,,,,


    I want it to read:

    word1,word2,word3,word4


    etc....
    the format for MULTICAT is =MULTICAT(A1:a500,",")

    Can someone suggest a way to either make multicat more appropriate for me, or a simple formula that will chop out the commas, except between words.

    many thanks even if u just took the time to read and can't help.
    Heres the MULTICAT code:
    '*****************************************
      'Purpose: Concatenate all cells in a range
      'Inputs:  rRng - range to be concatenated
      '         sDelimiter - optional delimiter
      '            to insert between cell Texts
      'Returns: concatenated string
      '*****************************************
      Public Function MultiCat( _
            ByRef rRng As Excel.Range, _
            Optional ByVal sDelim As String = "") _
                 As String
         Dim rCell As Range
         For Each rCell In rRng
             MultiCat = MultiCat & sDelim & rCell.Text
         Next rCell
         MultiCat = Mid(MultiCat, Len(sDelim) + 1)
      End Function
    Last edited by hi99ins; 03-10-2011 at 03:50 PM.

  2. #2
    Registered User
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: =MultiCat removing commas from a string

    Quote Originally Posted by TMShucks View Post
    Please add Code tags to your macro code.

    I think the solution is very simple ... but you need to follow the forum rules.

    Regards
    I am sorry but I didnt know what code tags are I got the code from another help site.are...I'll look em up and edit my post tks

  3. #3
    Registered User
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: =MultiCat removing commas from a string

    Quote Originally Posted by hi99ins View Post
    I am sorry but I didnt know what code tags are I got the code from another help site.are...I'll look em up and edit my post tks

    Done that now - I see what they are for - my bad.

  4. #4
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,238

    Re: =MultiCat removing commas from a string

    You need to select Go Advanced and click on the hash icon (#)


    Public Function MultiCat( _
        ByRef rRng As Excel.Range, _
        Optional ByVal sDelim As String = "") _
            As String
    Dim rCell As Range
    
    For Each rCell In rRng
        If rCell.Value <> "" Then
            MultiCat = MultiCat & sDelim & rCell.Text
        End If
    Next rCell
    
    MultiCat = Mid(MultiCat, Len(sDelim) + 1)
    End Function

    Regards

  5. #5
    Registered User
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    22

    Smile Re: =MultiCat removing commas from a string

    Quote Originally Posted by TMShucks View Post
    You need to select Go Advanced and click on the hash icon (#)


    Public Function MultiCat( _
        ByRef rRng As Excel.Range, _
        Optional ByVal sDelim As String = "") _
            As String
    Dim rCell As Range
    
    For Each rCell In rRng
        If rCell.Value <> "" Then
            MultiCat = MultiCat & sDelim & rCell.Text
        End If
    Next rCell
    
    MultiCat = Mid(MultiCat, Len(sDelim) + 1)
    End Function

    Regards
    Works like a dream thank you so much!!!

  6. #6
    Registered User
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: =MultiCat removing commas from a string

    Ok I am getting there - really appreciate your help - I will go read the posting rules in full b4 I post again...have a good evening and thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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