Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Count Rows macro MikeD1224 Excel Discussion (Misc queries) 3 February 19th 07 08:49 PM
Count number of rows, where non relevant rows are hidden Pieter Excel Discussion (Misc queries) 2 November 8th 06 12:24 PM
Count rows and insert number to count them. Mex Excel Discussion (Misc queries) 6 August 23rd 06 02:29 AM


All times are GMT +1. The time now is 03:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"