Hi all,
I have been working on a grouping of data in Column A based on data in column D. if the data in Column D matches next row in D then Concatenate data in column A and delete that line
any help appreciated to steer me in right direction
thanks regards Peter
Data Sample.jpg
My code so far
Sub CommandButton2_Click()
Dim x As Integer
Dim MyTimer As Double
x = MsgBox("This with now Group all Data IN Column A and Sheet1!", vbOKCancel)
If x = 2 Then Exit Sub
If x = 1 Then
MsgBox (" Application.EnableEvents = False")
'Application.EnableEvents = False
Dim Lastrow As Long, r As Long
Application.ScreenUpdating = False
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
'status bar code loop
' For j = 1 To 50
For r = Lastrow To 2 Step -1
If Range("D" & r).Value = Range("D" & r - 1).Value Then
Range("A" & r).Value = Range("A" & r - 1).Value & "_" & Range("A" & r).Value
Rows(r).Delete xlShiftUp
End If
'status bar code line under
' Application.StatusBar = "Progress: " & r & " of " & Lastrow & ": " & Format(r / Lastrow, "0%")
Next r
ActiveSheet.UsedRange.Columns.AutoFit
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.StatusBar = False
End If
End Sub
Bookmarks