Excel VBA to VBscript

  excel, vba, vbscript, web, windows

I’m trying to delete all the empty rows From an excel file that is created in VBScript. I found a way to do it in VBA but can’t do it in VBScript

I’m having a hard time converting the VBA code below to VBScript.

Dim LastRowIndex As Integer
Dim RowIndex As Integer
Dim UsedRng As Range

Set UsedRng = ActiveSheet.UsedRange
LastRowIndex = UsedRng.Row - 1 + UsedRng.Rows.Count
Application.ScreenUpdating = False

For RowIndex = LastRowIndex To 1 Step -1
    If Application.CountA(Rows(RowIndex)) = 0 Then
        Rows(RowIndex).Delete
    End If
Next RowIndex

Application.ScreenUpdating = True

I tried to do this on my own but the compiler would always return "Expected end of statement".

Dim LastRowIndex: LastRowIndex = 0
Dim RowIndex: RowIndex =0

Set UsedRng = xlApp.UsedRange
LastRowIndex = UsedRng.Row - 1 + UsedRng.Rows.Count
Application.ScreenUpdating = False

For RowIndex = LastRowIndex To 1 Step -1
    If Application.CountA(Rows(RowIndex)) = 0 Then
        Rows(RowIndex).Delete
    End If
Next RowIndex

Source: Windows Questions

LEAVE A COMMENT