1

I am using the below code in macro to delete blank rows in excel. Can you please help me in converting the same into Vbscript?

Columns("A:A").Select
   Selection.SpecialCells(xlCellTypeBlanks).Select
   Selection.EntireRow.Delete

waiting for your valuable response.

Anoop
  • 439
  • 2
  • 7
  • 12

1 Answers1

5

VBScript doesn't provide implicit parent objects like the VBA runtime environment does, so you need to make everything explicit:

Set xl = CreateObject("Excel.Application")
Set wb = xl.Workbooks.Add
Set ws = wb.Sheets(1)

ws.Columns("A:A").Select
...

Also, VBScript doesn't recognize VBA named constants, so you need to either use the numeric value:

...
xl.Selection.SpecialCells(4).Select
...

or define the constant in your script:

Const xlCellTypeBlanks = 4
...
xl.Selection.SpecialCells(xlCellTypeBlanks).Select
...

See here for more information about translating VBA to VBScript.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328