Micro Focus QTP (UFT) Forums
to count the number of used rows in a particular column - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: to count the number of used rows in a particular column (/Thread-to-count-the-number-of-used-rows-in-a-particular-column)



to count the number of used rows in a particular column - sujaravi123 - 06-11-2013

hi,
I have an excel sheet with different values for different columns
The used row count for each column is diffrent.

Can I get the used range count for a particular colum say eg:Column C.
I need to set this value as the limit for my For loop.

I tried the below but is useless as usedrange always returns the longest columns row count

Code:
Set Excel=createobject("excel.application")

Excel.visible = True
Set wkb = Excel.Workbooks.Open("D:\report period.xls")
Set ws = wkb.Sheets(1)
p=ws.UsedRange.Rows.Count



RE: to count the number of used rows in a particular column - supputuri - 06-12-2013

Used the below LOC long back... checkout and let me know if you need any help

Code:
intLastRow = Cells(Cells.Rows.Count,"A").End(xlUp).Row
OR
intEndRow = Cells(ActiveSheet.UsedRange.Rows.Count+1,ActiveCell.Column).End(xlUp).Row



RE: to count the number of used rows in a particular column - sujaravi123 - 06-12-2013

Itried both as below.But shows run time error Sad

Code:
intLastRow = Cells(ActiveSheet.Rows.Count,"A").End(xlUp).Row
OR
Code:
intEndRow = Cells(ActiveSheet.UsedRange.Rows.Count+1,ActiveCell.Column).End(xlUp).Row
--------------------------------------------------------------------------------


RE: to count the number of used rows in a particular column - sujaravi123 - 06-12-2013

used
rowcount= ws.Range("A65536").End(xlUp).Row also

didnt work