Results 1 to 2 of 2

Thread: Vb script Delete Empty Rows Excel

  1. #1

    Thread Starter
    Registered User
    Join Date
    Nov 2021

    Vb script Delete Empty Rows Excel

    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.

    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
           End If
    'Increment the counter down

  2. #2
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Idaho Falls, Idaho USA

    Re: Vb script Delete Empty Rows Excel

    For VBA, but can probably be adapted for use with VBScript:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width