AccountantinExcel
New Member
- Joined
- Sep 10, 2018
- Messages
- 10
I am trying to write a macro to remove rows with a cell value of zero in Range H4-H1003 and I1004-I2003.
Can anyone help with this?
Sub Remove_Empty_Cells()
Dim ws As Worksheet, last As Long, i As Long
For Each ws In Worksheets(Array("JE"))
ws.Activate
last = Cells(Rows.Count, "H1003").End(xlUp).Row 'Delete rows
For i = last To 3 Step -1
If Cells(i, "H1003").Value = 0 Then
Cells(i, "H4").EntireRow.Delete
End If
Next i
last = Cells(Rows.Count, "I2003").End(xlUp).Row 'Delete rows
For j = last To 3 Step -1
If Cells(i, "I2003").Value = 0 Then
Cells(i, "I1004").EntireRow.Delete
End If
Next j
Next ws
End Sub
Thanks!
Can anyone help with this?
Sub Remove_Empty_Cells()
Dim ws As Worksheet, last As Long, i As Long
For Each ws In Worksheets(Array("JE"))
ws.Activate
last = Cells(Rows.Count, "H1003").End(xlUp).Row 'Delete rows
For i = last To 3 Step -1
If Cells(i, "H1003").Value = 0 Then
Cells(i, "H4").EntireRow.Delete
End If
Next i
last = Cells(Rows.Count, "I2003").End(xlUp).Row 'Delete rows
For j = last To 3 Step -1
If Cells(i, "I2003").Value = 0 Then
Cells(i, "I1004").EntireRow.Delete
End If
Next j
Next ws
End Sub
Thanks!