none
How to merge different rows in Excel based on a condition RRS feed

  • Question

  • Hi,

    I have a sheet having 4 columns, through VBA macro, I am inserting rows on button click.

    What i want is that, when  Epic column values are same than comments cell range should be merged.

    Please see the attached screenshot.

    Help would be highly appreciated. 
    • Edited by Sonu888 Thursday, October 20, 2016 1:55 PM
    Thursday, October 20, 2016 1:52 PM

Answers

All replies

  • Re:  adjusting comments

    Delete the unwanted comment... 
       Range("C3").Comment.Delete

    Double the heigth of the other comment...
      Range("C2").Comment.Shape.Height = Range("C2").Comment.Shape.Height * 2

    ---
    Jim Cone
    Portland, Oregon USA
    https://goo.gl/IUQUN2 (Dropbox)
    (free & commercial excel add-ins & workbooks)

    • Edited by James Cone Friday, October 21, 2016 1:56 PM
    Friday, October 21, 2016 1:14 PM
  • Re: adusting comments - 2nd version

    A different interpretation of the question...
    '---
    Sub testExample()
      Dim strEntry As String
      strEntry = Range("C2").Comment.Text & " " & Range("C3").Comment.Text
      Range("C3").Comment.Delete
      Range("C2").Comment.Text Text:=strEntry
    End Sub

    '---
    Jim Cone


    • Marked as answer by Sonu888 Tuesday, October 25, 2016 2:37 PM
    Friday, October 21, 2016 1:56 PM
  • This will do what you want.

    Sub Macro()
    Dim lngRow As Long
    For lngRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
    If StrComp(Range("B" & lngRow), Range("B" & lngRow - 1), vbTextCompare) = 0 Then
    If Range("C" & lngRow) <> "" Then
    Range("C" & lngRow - 1) = Range("C" & lngRow - 1) & "|" & Range("C" & lngRow)
    End If
    Rows(lngRow).Delete
    End If
    Next
    End Sub




    MY BOOK


    • Edited by ryguy72 Thursday, November 10, 2016 5:14 PM
    Thursday, November 10, 2016 5:13 PM