+ Reply to Thread
Results 1 to 5 of 5

Looping a macro

  1. #1
    Registered User
    Join Date
    01-10-2008
    Posts
    27

    Looping a macro

    Hello, i was wondering how i would loop this macro (and others like it) all the way down to cell 66500 or what ever the last one is.

    Here is my macro

    Please Login or Register  to view this content.
    Thanks.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Please Login or Register  to view this content.
    will give you a range of row to cycle through, assuming that column A will contain an entry that determines the last row.

    The bit of you code
    Please Login or Register  to view this content.
    shows you want to clear every 5th row, but what is the value of n? Do you want to clear rows 5,10,15....?

    If you have a row that can give a mod of 0, then you could do something like

    Please Login or Register  to view this content.
    HTH

    rylo

  3. #3
    Registered User
    Join Date
    01-10-2008
    Posts
    27
    hmm...you said mod a couple times, what do you mean by it?

    your macro got an error on the row

    Please Login or Register  to view this content.
    and also, what exactly does this mean:

    Please Login or Register  to view this content.

    I just ask because i want to be able to learn how to do loops my own

    Thanks.

    Paul

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Paul

    1) Mod it the function that
    Returns the remainder after number is divided by divisor. The result has the same sign as divisor.
    So if you divide 10 by 5, then the remainder is 0. Basically it is a way to determine every 5th row.

    2) What you are doing is creating a loop that counts from 1 to ???. The ??? is determined to be the last filled row in column A (
    Please Login or Register  to view this content.
    ) For every iteration, i increments by 1. This is the default, and you can change the amount it increments by using the step argument. Have a look at the help file on the for loop.

    3) I put some numbers into a range on a sheet from A1:A50. Then run the code

    Please Login or Register  to view this content.
    It will clear out every 5th row (ie 5,10,15....)

    HTH

    rylo

  5. #5
    Registered User
    Join Date
    01-10-2008
    Posts
    27
    Awesome, Thanks! it works now and it pointed me int he right direction for looping stuff

+ 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