insert line in between different values

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
598
Office Version
  1. 2019
Platform
  1. 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:
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,

 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,215,059
Messages
6,122,916
Members
449,093
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top