nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 598
- Office Version
- 2019
- Platform
- Windows
I am creating a macro that will clean up a large list ofdata. It is currently deleting any rowswith empty cells and then sorting. Thisall works fine.
The next thing I need is for my macro to start in row 2 andcheck the value in column D and when it goes to row 3, if the value of column dis not equal to the value in row 2, it should insert a line separating them.
This the code I have so far:
Thank you,
The next thing I need is for my macro to start in row 2 andcheck the value in column D and when it goes to row 3, if the value of column dis not equal to the value in row 2, it should insert a line separating them.
This the code I have so far:
HTML:
Sub cleanUpSheet()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Range("C:D,F:H,J:V,X:AM").EntireColumn.Delete
Do Until IsEmpty(Cells(2, 2).Value) = False
If IsEmpty(Cells(2, 2).Value) = True Then
Rows(2).Select
Selection.Delete
End If
Loop
ActiveSheet.Range("A1").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("WDOPSC73_WEEKLY_PRIORITY_REPORT").AutoFilter.Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("WDOPSC73_WEEKLY_PRIORITY_REPORT").AutoFilter.Sort. _
SortFields.Add Key:=Range("D:D"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("WDOPSC73_WEEKLY_PRIORITY_REPORT").AutoFilter. _
Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Selection.AutoFilter
finalrow = Cells(Rows.Count, 2).End(xlUp).Row
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Thank you,