+ Reply to Thread
Results 1 to 3 of 3

Counting

  1. #1
    Mike
    Guest

    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. #2
    Norman Jones
    Guest

    Re: 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" <Mike@discussions.microsoft.com> wrote in message
    news:7A52145E-F4BB-4561-8224-0BBC2374A274@microsoft.com...
    > 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. #3
    Mike
    Guest

    Re: 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" <Mike@discussions.microsoft.com> wrote in message
    > news:7A52145E-F4BB-4561-8224-0BBC2374A274@microsoft.com...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1