+ Reply to Thread
Results 1 to 7 of 7

Looping cells with offsets?

  1. #1
    Registered User
    Join Date
    06-19-2015
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    30

    Looping cells with offsets?

    Hello everybody!

    I am creating an attendance sheet for my school and I'm trying to make it as simple for other users as is possible. The issue I am having with it now is trying to get the dates to line up with the correct days. Our sheet looks like this:

    Dates2.png

    The sheets are separated by month, from September to June, with the dates in rows D, I, N, S, X; and columns 3,31, 59, 87, 115.

    I manually insert the first date of the year (9/1/2015) in the proper place. I was trying to figure out how to loop through each cell and check if it is filled with the maroon color, and then if so to reference the cell 5 rows behind to see if that cell has numbers or not. If the cell 5 rows behind does have numbers (meaning the date), then reference that cell, and perform the formula in the originally selected cell "=[referenced cell]+1". If the cell 5 rows behind did not have numbers, then it should loop to the next colored cell.

    What I have so far is this:
    Please Login or Register  to view this content.
    Does this make any sense? Any help is greatly appreciated.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Looping cells with offsets?

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    06-19-2015
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    30

    Re: Looping cells with offsets?

    Here is a sample workbook with before and after sheets.

    Thanks so much!

    AttendanceTest.xlsm

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Looping cells with offsets?

    The sheets are separated by month, from September to June, with the dates in rows D, I, N, S, X; and columns 3,31, 59, 87, 115.
    Columns have letters, rows have numbers.
    It sounds like you are just wanting to fill in the dates.

    Why can't you just put a formula in each date cell in a template and when you add the first date in the sheet the rest of the cells will automatically fill in with the date?

    No VBA code needed.

  5. #5
    Registered User
    Join Date
    06-19-2015
    Location
    Michigan
    MS-Off Ver
    2010
    Posts
    30

    Re: Looping cells with offsets?

    Whoops! You are right, I misspoke about the columns and rows.

    I'm not sure what you mean by putting a formula in the cells in a template. Do you mean saving the file as a template? Also I need it to be specific dates that are easy to update each year. Would that be possible with a template?

    Thanks!

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Looping cells with offsets?

    In your example before sheet you would leave D3 empty since that will never need a formula.
    In I3 the formula would be =D3+1
    In N3 the formula would be =I3+1 etc.
    When you then enter a date in D3 the other cells will update for each Monday you have to have the formula equal to the previous Friday + 3

  7. #7
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Looping cells with offsets?

    Okay now I see what you want. You threw me off by putting 9/8 as your first date.

    So with this macro you can start with your calendar blank or you can leave the previous dates in as long as you clear the dates that are before the one you want to start with.
    For instance in the sample file I've uploaded there is an existing calendar for November with the 2nd being the date in the first Monday.
    So if you wanted to do one for December with the 1st being in Tuesday then just clear out D3 and put December 1st in to cell I3 and you can leave the other dates beyond that cell in and you'll be fine, the code will change dates and empty all cells after the month ends.

    I put a button in cell A1 to make it easy to run the macro.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by skywriter; 11-23-2015 at 05:00 PM.

+ 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. Cut, destination with offsets
    By SIMBAtheCAT in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2014, 02:56 PM
  2. GPS Offsets
    By briggsa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2013, 06:18 AM
  3. How to calculate GPS XY offsets
    By briggsa in forum Excel General
    Replies: 3
    Last Post: 12-11-2013, 06:09 AM
  4. [SOLVED] If statement and offsets
    By rlkerr in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-02-2012, 11:33 AM
  5. COUNTIF and relative offsets from current cells
    By mikejc in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-16-2011, 04:08 AM
  6. [SOLVED] dynamic offsets
    By lost in forum Excel General
    Replies: 3
    Last Post: 01-08-2006, 03:35 AM
  7. Easy one about offsets
    By carg1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2005, 01:36 PM

Tags for this Thread

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