简体   繁体   中英

How to count total number of rows of an excel column using UFT/VBSCRIPT

Set ExcelObj = createobject("excel.application")
ExcelObj.Visible = true
Set ExcelConfigFile = ExcelObj.Workbooks.Open (Path)
Set Sheet = ExcelConfigFile.Worksheets("Scripts")
TotalRow = Sheet.UsedRange.Rows.Count

So far, I get total rows of the sheet. I have a column called "key". How can I count total number of rows in the key column?

Try the below code to find number of rows in column - just change the Range("A1048576") to Range("B1048576")/Range("C1048576") etc to find individual row count for columns

Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Visible = true
Set ExcelConfigFile = ExcelObj.Workbooks.Open("C:\Users\pankaj.jaju\Desktop\Work.xlsx")
Set Sheet = ExcelConfigFile.Worksheets("Scripts")
TotalRow = Sheet.Range("A1048576").End(-4162).Row 'xlUp = -4162
MsgBox TotalRow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM