Need some help writing a VB script that gets the used range within excel then loops through each row within the used range and if the whole row is empty it deletes that row in excel.
The following code im using just deletes all the rows in the used range.
Any help is Greatly appreciated.
Code:
Dim objXL, WB, MyRange
On Error Resume Next
Set objXL = GetObject(, "Excel.Application")
Set WB = objXL.ActiveWorkbook
Set WS = objXL.ActiveWorkbook.Sheets(1)
Set MyRange = WS.UsedRange
'Start reverse looping through the range.
For iCounter = MyRange.Rows.Count To 1 Step -1
'If entire row is empty then delete it.
If objXL .CountA(Rows(iCounter).EntireRow) = 0 Then
WS.Rows(iCounter).Delete
End If
'Increment the counter down
Next