PDA

View Full Version : Solved: row count for specific column



benong
10-18-2010, 12:33 AM
hi,
i would like to find out the row count for a particular column, how can i do it?
eg.
Column A has 3 rows of data.
Column B has 5 rows of data.
Column C has 9 rows of data.
Column D has 2 rows of data.
Column E has 6 rows of data.

benong
10-18-2010, 01:23 AM
i try this code but it always give me the row count of column A

RowCount = Worksheets("Sheet1").Range(columnField & "1").CurrentRegion.Rows.Count

GTO
10-18-2010, 02:06 AM
Maybe:

Sub exa()
MsgBox GetCountA("Sheet2", 3)
End Sub

Function GetCountA(SheetName As String, Col As Long) As Long
Dim wks As Worksheet, rng As Range

Set wks = ThisWorkbook.Worksheets(SheetName)
Set rng = wks.Range(wks.Cells(1, Col), wks.Cells(wks.Rows.Count, Col))

GetCountA = Application.CountA(rng)
End Function

benong
10-18-2010, 06:24 PM
dear GTO,
many thanks.

benong
10-18-2010, 07:02 PM
this works for me :)
Range("A" & Rows.Count).End(xlUp).Row