#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Counting

How can I add something to a variable each time I run the macro? So
basically, I have a variable called CountRows, and each time I run the macro,
I want CountRows to increase by a certain number (different each time it is
ran). I just want it to keep a tally. So I have another variable called Rows.
I thought I could do the following:

CountRows = CountRows + Rows

Then the next time it is ran for a different sheet, it will remember what
was in CountRows and add the new Rows number to it.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Counting

Hi Mike,

One way, try something like:

'==============
Sub Tester02()
Dim iRows As Long
Static countRows As Long

iRows = Cells(Rows.Count, "A").End(xlUp).Row
countRows = countRows + iRows

End Sub
'<<==============


---
Regards,
Norman



"Mike" wrote in message
...
How can I add something to a variable each time I run the macro? So
basically, I have a variable called CountRows, and each time I run the
macro,
I want CountRows to increase by a certain number (different each time it
is
ran). I just want it to keep a tally. So I have another variable called
Rows.
I thought I could do the following:

CountRows = CountRows + Rows

Then the next time it is ran for a different sheet, it will remember what
was in CountRows and add the new Rows number to it.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Counting

THANK YOU!

"Norman Jones" wrote:

Hi Mike,

One way, try something like:

'==============
Sub Tester02()
Dim iRows As Long
Static countRows As Long

iRows = Cells(Rows.Count, "A").End(xlUp).Row
countRows = countRows + iRows

End Sub
'<<==============


---
Regards,
Norman



"Mike" wrote in message
...
How can I add something to a variable each time I run the macro? So
basically, I have a variable called CountRows, and each time I run the
macro,
I want CountRows to increase by a certain number (different each time it
is
ran). I just want it to keep a tally. So I have another variable called
Rows.
I thought I could do the following:

CountRows = CountRows + Rows

Then the next time it is ran for a different sheet, it will remember what
was in CountRows and add the new Rows number to it.




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
counting function but not double counting duplicates JRD Excel Worksheet Functions 2 November 7th 07 06:43 PM
Help Counting SS Excel Worksheet Functions 3 March 14th 06 06:27 PM
Counting rows, then counting values. Michael via OfficeKB.com Excel Discussion (Misc queries) 7 August 4th 05 10:57 PM
Counting Rows Then Counting Values in Columns Michael via OfficeKB.com Excel Programming 1 June 1st 05 04:10 PM
Counting names in a column but counting duplicate names once TBoe Excel Discussion (Misc queries) 9 May 11th 05 11:24 PM


All times are GMT +1. The time now is 05:40 AM.

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

About Us

"It's about Microsoft Excel"