Results 1 to 10 of 24

Thread: Flexible Concatenation Function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    14
    Quote Originally Posted by javanchi View Post
    Rick, data can go into the adjacent columns to the right of the data fields. All is text, but that field shows an error because the cell starts with an "=".
    I'm glad I asked about that #NAME? error as those lines of code required special handling. Give this macro a try...
    Code:
    Sub ConcatDashedRanges()
      Dim NextRow As Long, TempText As String, EmptyCells As Range, EqualSignCells As Range, Ar As Range
      On Error Resume Next
      Set EqualSignCells = Columns("A").SpecialCells(xlFormulas)
      For Each Ar In EqualSignCells
        Ar.Value = "'" & Ar.Formula
      Next
      Set EmptyCells = Columns("A").SpecialCells(xlConstants)
      For Each Ar In EmptyCells.Areas
        NextRow = NextRow + 1
        TempText = Application.Trim(Join(Application.Transpose( _
                   Ar.Offset(1).Resize(Ar.Count - 1).Value), ";"))
        If Left(TempText, 1) = "=" Then TempText = "'" & TempText
        Cells(NextRow, "B").Value = TempText
      Next
    End Sub
    I highlighted in red the location where the delimiter is specified in case you want to change it in the future.
    Last edited by Rick Rothstein; 02-14-2013 at 05:54 AM.

Similar Threads

  1. UDF (user defined function) replacement for Excel's DATEDIF function
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 21
    Last Post: 03-07-2015, 09:47 PM
  2. FORMATTED Flexible Concatenation Function
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 1
    Last Post: 10-14-2012, 03:48 PM

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
  •