Hi,
I have the following VBA which is meant to delete rows if the value in cell in column C equals 0
And it works but it's only applying to one sheet and i want it to run across the entire workbook
Sub RemoveRow()
Dim xSh As Worksheet
Application.ScreenUpdating = False
For Each xSh In Worksheets
xSh.Select
Call RunCode
Next
Application.ScreenUpdating = True
End Sub
Sub RunCode()
Columns("C:C").Select
Set rngRange = Selection.CurrentRegion
lngNumRows = rngRange.Rows.Count
lngFirstRow = rngRange.Row
lngLastRow = lngFirstRow + lngNumRows - 1
lngCompareColumn = ActiveCell.Column
For lngCurrentRow = lngLastRow To lngFirstRow Step -1
If (Cells(lngCurrentRow, lngCompareColumn).Text = "0") Then _
Rows(lngCurrentRow).Delete
Next lngCurrentRow
End Sub
What can be modified for it to work on the entire workbook
I have the following VBA which is meant to delete rows if the value in cell in column C equals 0
And it works but it's only applying to one sheet and i want it to run across the entire workbook
Sub RemoveRow()
Dim xSh As Worksheet
Application.ScreenUpdating = False
For Each xSh In Worksheets
xSh.Select
Call RunCode
Next
Application.ScreenUpdating = True
End Sub
Sub RunCode()
Columns("C:C").Select
Set rngRange = Selection.CurrentRegion
lngNumRows = rngRange.Rows.Count
lngFirstRow = rngRange.Row
lngLastRow = lngFirstRow + lngNumRows - 1
lngCompareColumn = ActiveCell.Column
For lngCurrentRow = lngLastRow To lngFirstRow Step -1
If (Cells(lngCurrentRow, lngCompareColumn).Text = "0") Then _
Rows(lngCurrentRow).Delete
Next lngCurrentRow
End Sub
What can be modified for it to work on the entire workbook