Forum Discussion

LarryHarrison1988's avatar
LarryHarrison1988
Copper Contributor
Jul 08, 2024

Need help with macro

I have the following macro that someone made for me a few years ago. In it, it is tied to a certain page. I need to be able to run the macro on the page that I am working on without having to change ...
  • HansVogelaar's avatar
    HansVogelaar
    Jul 10, 2024

    LarryHarrison1988 

    My apologies, a stupid mistake on my side. Step -2 should have been Step -1.

    Sub Macro1()
        Dim r As Long
        Dim m As Long
    
        Application.ScreenUpdating = False
    
        m = Range("E" & Rows.Count).End(xlUp).Row
        Range("A7:I" & m).Sort Key1:=Range("E7"), Key2:=Range("A7"), Header:=xlYes
    
        For r = m - 1 To 8 Step -1
            If Range("E" & r).Value <> Range("E" & r + 1).Value Then
                Range("E" & r + 1).EntireRow.Insert
            End If
        Next r
    
        Application.ScreenUpdating = True
    End Sub

Resources