deleting data with macro

volkl77

Board Regular
Joined
Apr 5, 2008
Messages
76
I have recorded all the steps of my macro and it is working fine but i would like to add 2 more steps.

1 First I would like to have it delete all the rows where the values in both columns I and J are "0"

2 After this i would like to have it sort the sheet by column 1.

Any help would be greatly appreciated.

Thanks!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I have recorded all the steps of my macro and it is working fine but i would like to add 2 more steps.

1 First I would like to have it delete all the rows where the values in both columns I and J are "0"

2 After this i would like to have it sort the sheet by column 1.

Any help would be greatly appreciated.

Thanks!

Maybe:

Code:
Sub volkl77()
Dim lr As Long

Dim i As Long

lr = Cells(Rows.Count, 1).End(xlUp).Row

For i = lr To 2 Step -1

    If Range("I" & i).Value = 0 And Range("J" & i).Value = 0 Then
    
        Range("I" & i).EntireRow.Delete shift:=xlUp
        
    End If
    
Next i

Range("A2:A" & lr).Sort Key1:=Range("A2"), Order1:=xlDescending

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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