ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Count Rows (https://www.excelbanter.com/excel-programming/333449-macro-count-rows.html)

anonymous

Macro to Count Rows
 
Hi, I'm hoping some of you Excel Guru's can enlighten me.
Here's what I'm trying to do:

I have a sheet open and I paste a column of values in.
I don't know how many rows are in the list since it will change every time I
want to run this process.
I'd like to hit a macro key and get a count of the number of rows in column
1.

Is there a way to do this?

Thanks for any help!
Bruno



Mike Fogleman

Macro to Count Rows
 
Hi Bruno, try this:

ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row

Mike F
"anonymous" wrote in message
...
Hi, I'm hoping some of you Excel Guru's can enlighten me.
Here's what I'm trying to do:

I have a sheet open and I paste a column of values in.
I don't know how many rows are in the list since it will change every time
I
want to run this process.
I'd like to hit a macro key and get a count of the number of rows in
column
1.

Is there a way to do this?

Thanks for any help!
Bruno





Ken Hudson

Macro to Count Rows
 
In case you need some help setting up the macro:

Press Ctrl and F11 to open the Visual Basic Editor.
Select Insert and then Module.
Copy the code below and paste it into the module.
Close the Editor.
Back in the Excel workbook select Tools Macro Macros... (Excel 2003)
Click the Options... button and enter "r" in the shortcut box.
Press OK and close the dialog box.
Control r (Ctrl + r) should then run your macro.
---------------------------------
Option Explicit

Sub CountRows()
Dim Msg As Integer
Msg = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
MsgBox "Number of rows = " & Msg & "."
End Sub


HTH
--
Ken Hudson


"anonymous" wrote:

Hi, I'm hoping some of you Excel Guru's can enlighten me.
Here's what I'm trying to do:

I have a sheet open and I paste a column of values in.
I don't know how many rows are in the list since it will change every time I
want to run this process.
I'd like to hit a macro key and get a count of the number of rows in column
1.

Is there a way to do this?

Thanks for any help!
Bruno





All times are GMT +1. The time now is 10:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com