Hi,
I cannot figure out why this macro only runs on the active worksheet and not all worksheets in the workbook. The macro is to delete rows with a zero value in the end colum (in this case colum G). Can anyone advise? thanks
Code:Sub Delete_zero_Rows() Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets Dim lastrow As Long, r As Long lastrow = ws.UsedRange.Rows.Count For r = lastrow To 1 Step -1 If UCase(Cells(r, 7).Value) = "0" Then Rows(r).Delete Next r Next ws Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub
Last edited by jbyrne; 03-15-2010 at 10:40 AM.
Because this line:
needs to be this:Code:If UCase(Cells(r, 7).Value) = "0" Then Rows(r).Delete
Code:If UCase(ws.Cells(r, 7).Value) = "0" Then ws.Rows(r).Delete
So long, and thanks for all the fish.
thanks romperstomper. that did the trick
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks