Count number of rows in col A in vba? simple, right?

Phutile

Board Regular
Joined
Jul 8, 2002
Messages
85
I'm looking to get the count of rows in column A. Before I was putting a formula into a cell and then pulling that value out of the cell and putting it into a variable. How can I avoid having to put this in the cell to get a count of the number of rows in column A that have a value?

Range("Z1").Formula = "=MATCH(9.9999999E+307,Richburg!A:A)"
Range("Z1").Font.Color = RGB(255, 255, 255)
Test = Range("Z1").Value

I also tried Test = Range(A:A).Count and that didn't work for me either. What am I doing wrong
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hullo. Given that there are no blank cells in col A, this UNTESTED snippet should work:
Code:
Range(.Range("A1"), .Range("A65535").End(xlUp)).Count

HTH

P
 
Upvote 0
Is there a way I could count the number of selected rows? I'm trying to write a macro to emulate the copy/paste column width but rather row height.

basically I want to have the macro count the number of selected rows, update a dynamic array to be the size of the count of rows selected, read the row heights sequentially into the array, then the paste macro will take that array, and update sequentially the rows with the copied row starting at the row you select before running the paste macro.

If someone knows how to quickly write this it would solve the underlying problem, and not just this quick question on how to count the number of selected rows, either way any help is greatly appreciated.

Thanks!
 
Upvote 0
I appreciate the input! I used this on a spreadsheet just now... and since I was getting user selected data... it looked like this...

Dim mainrange as RANGE
Dim X as INTEGER
Dim a as STRING
'------------------------------------
Set mainrange = Selection
x = mainrange.Count
a = "Correcting " + Str(x) + " lines"
Application.Speech.Speak (a)


This way my routine can tell the user how many lines it is currently working on.
~Jerry
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,565
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top