+ Reply to Thread
Results 1 to 4 of 4

How to repeat a subset of commands in VBA?

  1. #1
    Registered User
    Join Date
    08-31-2013
    Location
    Berea, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    2

    How to repeat a subset of commands in VBA?

    Hi everyone, VBA noob here. I'm trying to make a robust attendance tracker for my director, and am approaching the finish line. On the first sheet is the roster of people with adjacent drop-downs to select "here" or "absent,", and on the second sheet is a tracker that records the date each time someone is marked absent and counts the total.

    I have created a button that "resets" the form, which I've defined as changing everyone's status back to "here," and converts the formulas on the second sheet that record the date to their value (like F9 function), then copies the same formula over 1 cell. Here's my code:

    Please Login or Register  to view this content.
    This works successfully with one person, and now I just want to repeat the first 3 commands through the range B3:B47.
    Would this require a Loop?

    Thanks,
    JordanAbu
    Last edited by jeffreybrown; 09-01-2013 at 02:36 PM. Reason: As per Forum Rule #3, please use code tags…Thanks.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: How to repeat a subset of commands in VBA?

    Try

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    08-31-2013
    Location
    Berea, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: How to repeat a subset of commands in VBA?

    Thanks Martin! It didn't work at first, but I realized it was because I needed to re-reference the Sheet (the command button is located on a different sheet)

    I then realized, though, that I have another issue:
    I need "B5" in the formula below to instead be a variable also, which cycles through these ranges in this order: B5:B14, D5:D15, F5:F17, H5:H16

    IF(OR(INDIRECT(""RC[-1]"",0)=Form!$C$2,INDIRECT(""RC[-1]"",0)=""""),"""",IF(Form!$B5=""Absent"",TODAY(),""""))"

    This will equal the 46 cycles of N (2 to 47). I'm not sure this is possible, and I suppose I could create 4 different subs - one for each column, but the less code the better!

    Thanks,
    JordanAbu
    Last edited by jordanabu; 09-02-2013 at 04:09 PM.

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: How to repeat a subset of commands in VBA?

    I would suggest defining a name for the range B5:B14, D5:D15, F5:F17, H5:H16 and then using a for Each loop to sequentially create you formulae.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro Recording Chart Format commands missing all important commands!!!!
    By nounours in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2013, 09:20 PM
  2. Subset Sum Problem
    By smuzoen in forum Excel Tips
    Replies: 0
    Last Post: 07-05-2012, 09:55 AM
  3. Max value from column subset?
    By Carolina in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-16-2011, 08:51 AM
  4. [SOLVED] How to enter symbols for subset or element of a subset in Excel?
    By rwcita in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-23-2006, 05:30 PM
  5. Replies: 2
    Last Post: 08-24-2005, 12:05 PM

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