1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

[Excel] Need some help

Discussion in 'BBS Hangout' started by ElPigto, Aug 9, 2011.

  1. ElPigto

    ElPigto Member
    Supporting Member

    Joined:
    Sep 21, 2006
    Messages:
    16,185
    Likes Received:
    26,019
    I've helped developed a spreadsheet where I input a starting date and a lot of other cells are populated based on a formula for that cell. The spreadsheet so far avoids outputting weekends and also holidays. However, I need a way where I can get certain cells to give me only certain days of the week. For example, I want a cell to give me only Tuesdays, so if a date comes during at a Monday, I need the date automatically be bumped up to a Tuesday or if the date is after Tuesday I need it to bump it to next Tuesday.

    Is this something excel can do, or do I need to create my own function (which I've never done)?

    I'd appreciate any help. Thanks!
     
  2. JayZ750

    JayZ750 Member

    Joined:
    May 16, 2000
    Messages:
    25,432
    Likes Received:
    13,390
    I don't know a good answer. All I can think of would be if you have a start date that is a Tuesday - say today - then for each output date, you could take that output date and subtract the start date, then divide that number by 7. Then roundup that number, so it will always roundup to an integer, than multiple the roundup by 7 and add to your original start date.

    For example, today is 8-9-11, which excel stores as 40,764.

    So you have a formula, and it outputs 8-25-11... which is a Thursday. Excel has this as 40,780.

    (1) 40,780 - 40,764 = 16
    (2) 16/7 = 2.286
    (3) Roundup(2.286,0) = 3
    (4) 3 * 7 = 21
    (5) 40,764 + 21 = 40,785

    40,785 happens to be Tuesday, 8-30-11.

    It works, but isn't very pretty, and you'd have to think about how to roundup with different start dates, or if it does land on the Tuesday and you want to roundup to the next Tuesday. maybe it will at least get your brain thinking.
     
  3. ScriboErgoSum

    ScriboErgoSum Member
    Supporting Member

    Joined:
    Aug 5, 2002
    Messages:
    3,150
    Likes Received:
    388
    You're going to have to use a function. The WEEKDAY function will do what you're looking for.

    =WEEKDAY(A1) returns a numeric value, corresponding to the day of the week for the value in A1. 1=Sunday, 2=Monday,...,7=Saturday.

    So for your example, you could use:

    =IF(WEEKDAY(A1)<3,A1+(3-WEEKDAY(A1)),IF(WEEKDAY(A1)>3,A1+(10-WEEKDAY(A1)),A1))
     
    1 person likes this.
  4. JayZ750

    JayZ750 Member

    Joined:
    May 16, 2000
    Messages:
    25,432
    Likes Received:
    13,390
    ^

    I was going to edit, but just did a quick google and found the weekday function. So what Scribo said. You might want to adjust his function to replace the 3 with a hard-code cell reference, so if you want to find Wednesday's instead of Tuesday, you just have to change the one cell.
     
  5. ScriboErgoSum

    ScriboErgoSum Member
    Supporting Member

    Joined:
    Aug 5, 2002
    Messages:
    3,150
    Likes Received:
    388
    I agree with JayZ750. You can create a little lookup table with the numbers 1-7, and use the Insert->Name->Define you name them Sunday - Saturday.
     
  6. Rocket1

    Rocket1 Member

    Joined:
    Jan 16, 2008
    Messages:
    590
    Likes Received:
    9
    1 person likes this.

Share This Page

  • About ClutchFans

    Since 1996, ClutchFans has been loud and proud covering the Houston Rockets, helping set an industry standard for team fan sites. The forums have been a home for Houston sports fans as well as basketball fanatics around the globe.

  • Support ClutchFans!

    If you find that ClutchFans is a valuable resource for you, please consider becoming a Supporting Member. Supporting Members can upload photos and attachments directly to their posts, customize their user title and more. Gold Supporters see zero ads!


    Upgrade Now