Hello,
I am working on a macro that would:
- delete all charts from the sheet
- select rows from row 1 to last row that has data; this range will have some full and some empty rows
- delete empty rows from this range
- move onto the next Sheet and repeat
- do this for all sheets in a Workbook
My Macro seems to be working more or less fine EXCEPT it would not do the "select rows, delete empty ones" on other sheets but the first one (one in focus). Any ideas what might be wrong?
Thanks!
Sub Delete_Charts_Rows_all_Sheets()
Dim Ws As Worksheet, chtObj As ChartObject, i As Long, Lastrow As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
For Each Ws In ThisWorkbook.Worksheets
For Each chtObj In Ws.ChartObjects
chtObj.Delete
Next
Lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Range("1:" & Lastrow).Select
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next
Next Ws
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Su
b
Bookmarks