+ Reply to Thread
Results 1 to 5 of 5

Looping a macro x times(x being activecell.value)?

  1. #1
    Shaka215@gmail.com
    Guest

    Looping a macro x times(x being activecell.value)?

    How do I loop a macro x amount of times from activecell.value?
    I need to have a macro repeat a process based on the value of say cell
    "T21".
    Please explain the loop process as detailed as possiable. Thank you
    fellow programmers!

    -Shaka215


  2. #2
    Ardus Petus
    Guest

    Re: Looping a macro x times(x being activecell.value)?

    Bonjour,

    Dim iCnt as integer
    For iCnt = 1 to Range("T21").value
    Call MyMacro
    Next iCnt

    Et voilà!

    --
    AP

    <Shaka215@gmail.com> a écrit dans le message de news:
    1152172938.163669.59230@b68g2000cwa.googlegroups.com...
    > How do I loop a macro x amount of times from activecell.value?
    > I need to have a macro repeat a process based on the value of say cell
    > "T21".
    > Please explain the loop process as detailed as possiable. Thank you
    > fellow programmers!
    >
    > -Shaka215
    >




  3. #3
    Thyagaraj
    Guest

    Re: Looping a macro x times(x being activecell.value)?


    Shaka215@gmail.com wrote:
    > How do I loop a macro x amount of times from activecell.value?
    > I need to have a macro repeat a process based on the value of say cell
    > "T21".
    > Please explain the loop process as detailed as possiable. Thank you
    > fellow programmers!
    >
    > -Shaka215



    Dear Shaka,

    Just try the following code :-

    Sub LoopTest()
    Dim n
    Dim V
    Range("T21").Select
    V = ActiveCell.Value
    n = 0
    Do Until n = V
    'your code
    n = n + 1
    Loop
    End Sub


  4. #4
    Shaka215@gmail.com
    Guest

    Re: Looping a macro x times(x being activecell.value)?

    Thanks! Worked great...

    Thyagaraj wrote:
    > Shaka215@gmail.com wrote:
    > > How do I loop a macro x amount of times from activecell.value?
    > > I need to have a macro repeat a process based on the value of say cell
    > > "T21".
    > > Please explain the loop process as detailed as possiable. Thank you
    > > fellow programmers!
    > >
    > > -Shaka215

    >
    >
    > Dear Shaka,
    >
    > Just try the following code :-
    >
    > Sub LoopTest()
    > Dim n
    > Dim V
    > Range("T21").Select
    > V = ActiveCell.Value
    > n = 0
    > Do Until n = V
    > 'your code
    > n = n + 1
    > Loop
    > End Sub



  5. #5
    Registered User
    Join Date
    07-07-2006
    Posts
    3

    Thumbs up looping macros

    First off, this is my first post on this site and i'm excited. I've used another site for years and recently i thought of looking at other sites- and talk about a sign or something; after registering the first topic i saw was the exact topic i was working on! WOW --- I think i've come to the right place!!!!!!!!!!

    so here we go


    how would i adapt this code
    ============================================================
    If [s6].Value = 1 Then Call addMC
    If [r6].Value = 1 Then Call addJar
    If [q6].Value = 1 Then Call add2oz
    If [p6].Value = 1 Then Call add8oz
    If [o6].Value = 1 Then Call add18oz
    If [n6].Value = 1 Then Call add32oz
    ===========================================================

    so that the macros that are called are run as many times as the value in their respective cells.

    Example: for the first line "If [s6].Value = 1 Then Call addMC" if cell S6 = 12 then the Macro AddMC will be run 12 times and if cell S6 = 2 then the macro would only me run twice or even if S6 = 0 then the macro would not be run. I think i've made my point. As you can see there is more then 2 or so seperate macros their respective cells to run every time this sub is run. Thanks

+ 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