How Can I Add a COUNTIF Formula to an Excel Spreadsheet?
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)
objExcel.Cells(1, 1).Value = "nkabc"
objExcel.Cells(2, 1).Value = "abcnk"
objExcel.Cells(3, 1).Value = "abnkc"
objExcel.Cells(4, 1).Value = "ank"
strFormula = "=COUNTIF(A1:A4," & Chr(34) & "NK*" & Chr(34) & ")"
objExcel.Cells(6, 1).Formula = strFormula
[Via]