1

I need to remove the whole row IF column A value is empty. I have been doing it in excel and this method works best for me

.Columns("a:a").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

I need to do the same thing using vbs however, I have issues converting it to vbs

How can I convert the above line into vbs?

I looked up the xlCellTypeBlanks = 4 using F2 . But how to use the SpecialCells method ?

2 Answers 2

1

Something like this

Const xlCellTypeBlanks = 4

Dim xlApp
Dim xlwb

Set xlApp = CreateObject("Excel.Application")
Set xlwb = xlApp.workbooks.Open("C:\temp\test.xlsm")
On Error Resume Next
xlwb.Sheets(1).Columns("a:a").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
Sign up to request clarification or add additional context in comments.

Comments

0

You will need to have an object for the Excel App, Workbook, Worksheet etc.. So something like

Dim xlApp as Object
Set xlApp = CreateObject("Excel.Application")
Dim wb as object
Set wb = xlApp.Open("YourWorbookName.xlsx")
wb.Worksheets("NameOfWorksheet").Columns("a:a").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

2 Comments

Of course I do have an object for all of the above. It is just this line SpecialCells(xlCellTypeBlanks). that does not compile in vbs
Add Const xlCellTypeBlanks = 4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.