232showtime Posted Friday at 04:53 AM Posted Friday at 04:53 AM Counting non-blank cell returns 16 $oExcel = ObjCreate("Excel.Application") Local $sWorkbook = "Z:\Test.xlsx" $oWorkbook = _Excel_BookAttach($sWorkbook) $oWorkbook.Worksheets("EXAMPLE").Activate $oRange = $oWorkbook.Activesheet.Range("D15:D30") MsgBox(4096, "Excel Count Non-Blank Cells", $oExcel.WorksheetFunction.CountA($oRange)) Counting non-blank cell returns 4 #include <Excel.au3> $oExcel = ObjCreate("Excel.Application") Local $oWorkbook = _Excel_BookOpen($oExcel, "Z:\Test.xlsx") $oRange = $oExcel.ActiveSheet.Range("D15:D30") MsgBox(4096, "Excel Count Non-Blank Cells", $oExcel.WorksheetFunction.CountA($oRange)) what's wrong with the first code? ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon.
Solution ioa747 Posted Friday at 08:36 AM Solution Posted Friday at 08:36 AM (edited) https://www.autoitscript.com/wiki/Excel_Range #include <Excel.au3> $oExcel = ObjCreate("Excel.Application") ;~ Local $sWorkbook = "Z:\Test.xlsx" Local $sWorkbook = @ScriptDir & "\Test.xlsx" Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) ;~ Local $oRange = $oWorkbook.Sheets(1).Range("D15:D30") Local $oRange = $oWorkbook.Worksheets("EXAMPLE").Range("D15:D30") ; 0 + if no value $NonBlankCount = 0 + $oExcel.WorksheetFunction.CountIf($oRange, "<>") MsgBox(4096, "Excel Count Non-Blank Cells", $NonBlankCount) ; Clean up $oWorkbook.Close(False) ; Close the workbook without saving $oExcel.Quit() ; Quit Excel Edited Friday at 10:19 AM by ioa747 added ; Clean up 232showtime 1 I know that I know nothing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now