I need to count the number of active cells in column A of Excel.
I can achieve this easily using 'worksheetfunction.countA' in Excel VBA, but unable to get the same in VBScript.
I have tried the following code:
Dim objXl , objWorkbook, objSheet ,numofactivecells
Set objXl = createobject("Excel.Application")
set objWorkbook= objXl.Workbooks.open("C:\Users\Username\Desktop\filename.xlsm")
'change filename
set objSheet = objWorkbook.Worksheets(1)
objXl.visible = true
objsheet.cells(1,1).select
numofactivecells = objsheet.WorksheetFunction.CountA(Range("A:A"))
msgbox numofactivecells
I need count of cells containing data in column A stored in variable.
I get the following error messages when I execute the code:
Microsoft VBScript compilation error: Expected identifier
Microsoft VBScript compilation error: Expected ')'