+ Reply to Thread
Results 1 to 14 of 14

Having a cell equal a specific day of the week?

  1. #1
    Registered User
    Join Date
    07-18-2006
    Posts
    73

    Having a cell equal a specific day of the week?

    Right now in some of my spreadsheets, I have cells equal to things such as =Today()-3 to go 3 days previous. In writing that I am actually looking to find the previous Friday, since I will be running this on Mondays. Is there a way to specifically call on "the previous Friday" so that if I happen to run it on Tuesday it will still pickup last Friday?

    I'm sure its a line of code, just not sure where to look for it.

    Thanks,

    ~J

  2. #2
    Niek Otten
    Guest

    Re: Having a cell equal a specific day of the week?

    =TODAY()-WEEKDAY(TODAY()-6)

    --
    Kind regards,

    Niek Otten
    Microsoft MVP - Excel

    "nbaj2k" <[email protected]> wrote in message
    news:[email protected]...
    |
    | Right now in some of my spreadsheets, I have cells equal to things such
    | as =Today()-3 to go 3 days previous. In writing that I am actually
    | looking to find the previous Friday, since I will be running this on
    | Mondays. Is there a way to specifically call on "the previous Friday"
    | so that if I happen to run it on Tuesday it will still pickup last
    | Friday?
    |
    | I'm sure its a line of code, just not sure where to look for it.
    |
    | Thanks,
    |
    | ~J
    |
    |
    | --
    | nbaj2k
    | ------------------------------------------------------------------------
    | nbaj2k's Profile: http://www.excelforum.com/member.php...o&userid=36480
    | View this thread: http://www.excelforum.com/showthread...hreadid=569940
    |



  3. #3
    ChasAA
    Guest

    RE: Having a cell equal a specific day of the week?

    Not sure if this what you want, but try this code

    Sub test()
    Range("A1").Select
    ' Have your date in Cell A1
    ' The loop will lookup the previous Friday
    ' and eneter that date two cells down
    For c = Selection.Value To (Selection.Value - 7) Step -1
    backdate = Format(c, "dddd dd mmm yyyy")
    If Left(backdate, 3) = "Fri" Then
    Selection.Offset(2, 0) = backdate
    End If
    Next
    End Sub

    Chas

    "nbaj2k" wrote:

    >
    > Right now in some of my spreadsheets, I have cells equal to things such
    > as =Today()-3 to go 3 days previous. In writing that I am actually
    > looking to find the previous Friday, since I will be running this on
    > Mondays. Is there a way to specifically call on "the previous Friday"
    > so that if I happen to run it on Tuesday it will still pickup last
    > Friday?
    >
    > I'm sure its a line of code, just not sure where to look for it.
    >
    > Thanks,
    >
    > ~J
    >
    >
    > --
    > nbaj2k
    > ------------------------------------------------------------------------
    > nbaj2k's Profile: http://www.excelforum.com/member.php...o&userid=36480
    > View this thread: http://www.excelforum.com/showthread...hreadid=569940
    >
    >


  4. #4
    Registered User
    Join Date
    07-18-2006
    Posts
    73

    i think this is it, but not sure what to put in for the number!

    =TODAY()-WEEKDAY(TODAY()-6)


    Thats the code I was looking for, just had a little brain lapse, couldn't figure out what the 6 was, I'm back with it though and figured it out!

    Thanks,

    ~J
    Last edited by nbaj2k; 08-09-2006 at 02:53 PM.

  5. #5
    Niek Otten
    Guest

    Re: Having a cell equal a specific day of the week?

    I suggest you try with several dates (instead of TODAY()) and several numbers (instead of just 6); I'm sure you'll see how it
    works real soon

    --
    Kind regards,

    Niek Otten
    Microsoft MVP - Excel


    "nbaj2k" <[email protected]> wrote in message
    news:[email protected]...
    |
    | I think I'm looking for more of what the first response was, not
    | necessarily a code, but something I can put in a sell sort of like
    |
    | =TODAY()-WEEKDAY(TODAY()-6)
    |
    | I'm just not sure exactly what that means and what number I have to put
    | in for it to equal a certain day sorry!
    |
    | Could someone just explain it?
    |
    | Thanks,
    |
    | ~J
    |
    |
    | --
    | nbaj2k
    | ------------------------------------------------------------------------
    | nbaj2k's Profile: http://www.excelforum.com/member.php...o&userid=36480
    | View this thread: http://www.excelforum.com/showthread...hreadid=569940
    |



  6. #6
    ChasAA
    Guest

    Re: Having a cell equal a specific day of the week?

    Try this formula.
    It will look up the previous Friday from the date you enter in Cell A1

    =IF(TEXT(A1-1,"dddd")="Friday",A1-1,IF(TEXT(A1-2,"dddd")="Friday",A1-2,IF(TEXT(A1-3,"dddd")="Friday",A1-3,IF(TEXT(A1-4,"dddd")="Friday",A1-4,IF(TEXT(A1-5,"dddd")="Friday",A1-5,IF(TEXT(A1-6,"dddd")="Friday",A1-6))))))

    Good Luck

    Chas
    PS Itried it and IT does work!!

    "nbaj2k" wrote:

    >
    > I think I'm looking for more of what the first response was, not
    > necessarily a code, but something I can put in a sell sort of like
    >
    > =TODAY()-WEEKDAY(TODAY()-6)
    >
    > I'm just not sure exactly what that means and what number I have to put
    > in for it to equal a certain day sorry!
    >
    > Could someone just explain it?
    >
    > Thanks,
    >
    > ~J
    >
    >
    > --
    > nbaj2k
    > ------------------------------------------------------------------------
    > nbaj2k's Profile: http://www.excelforum.com/member.php...o&userid=36480
    > View this thread: http://www.excelforum.com/showthread...hreadid=569940
    >
    >


  7. #7
    ChasAA
    Guest

    Re: Having a cell equal a specific day of the week?

    PS.
    I think the coded version was easier !!!!!!

    Chas

    "ChasAA" wrote:

    > Try this formula.
    > It will look up the previous Friday from the date you enter in Cell A1
    >
    > =IF(TEXT(A1-1,"dddd")="Friday",A1-1,IF(TEXT(A1-2,"dddd")="Friday",A1-2,IF(TEXT(A1-3,"dddd")="Friday",A1-3,IF(TEXT(A1-4,"dddd")="Friday",A1-4,IF(TEXT(A1-5,"dddd")="Friday",A1-5,IF(TEXT(A1-6,"dddd")="Friday",A1-6))))))
    >
    > Good Luck
    >
    > Chas
    > PS Itried it and IT does work!!
    >
    > "nbaj2k" wrote:
    >
    > >
    > > I think I'm looking for more of what the first response was, not
    > > necessarily a code, but something I can put in a sell sort of like
    > >
    > > =TODAY()-WEEKDAY(TODAY()-6)
    > >
    > > I'm just not sure exactly what that means and what number I have to put
    > > in for it to equal a certain day sorry!
    > >
    > > Could someone just explain it?
    > >
    > > Thanks,
    > >
    > > ~J
    > >
    > >
    > > --
    > > nbaj2k
    > > ------------------------------------------------------------------------
    > > nbaj2k's Profile: http://www.excelforum.com/member.php...o&userid=36480
    > > View this thread: http://www.excelforum.com/showthread...hreadid=569940
    > >
    > >


  8. #8
    ChasAA
    Guest

    Re: Having a cell equal a specific day of the week?

    Hello Again,
    Dont' bother using my formula. Use the one suggested by Neik. If you paste
    that in a cell it will always give you previous Friday.

    Nice One Neik, but I dont really understand how and why it works. I know
    that the 6 signifies Friday. Please explain if you dont mind

    ChasAA

    "nbaj2k" wrote:

    >
    > I think I'm looking for more of what the first response was, not
    > necessarily a code, but something I can put in a sell sort of like
    >
    > =TODAY()-WEEKDAY(TODAY()-6)
    >
    > I'm just not sure exactly what that means and what number I have to put
    > in for it to equal a certain day sorry!
    >
    > Could someone just explain it?
    >
    > Thanks,
    >
    > ~J
    >
    >
    > --
    > nbaj2k
    > ------------------------------------------------------------------------
    > nbaj2k's Profile: http://www.excelforum.com/member.php...o&userid=36480
    > View this thread: http://www.excelforum.com/showthread...hreadid=569940
    >
    >


  9. #9
    Registered User
    Join Date
    07-18-2006
    Posts
    73

    just one more thing?

    I was wondering, is there code like the one from Niek that would allow me to also pick something from 2 Fridays back, or Two Thursdays back and so on?

    I need one cell to equal one wednesday back and the other to be 2 wednesdays back

    This is the code for 1 Specific day back, just not sure what I would add to it to make it 2 specific days back (If you get what I'm saying)

    =TODAY()-WEEKDAY(TODAY()-6)

    Thanks,

    ~J

  10. #10
    Niek Otten
    Guest

    Re: Having a cell equal a specific day of the week?

    Subtract another 7 (that means another 7 days)

    --
    Kind regards,

    Niek Otten
    Microsoft MVP - Excel


    "nbaj2k" <[email protected]> wrote in message
    news:[email protected]...
    |
    | I was wondering, is there code like the one from Niek that would allow
    | me to also pick something from 2 Fridays back, or Two Thursdays back
    | and so on?
    |
    | I need one cell to equal one wednesday back and the other to be 2
    | wednesdays back
    |
    | This is the code for 1 Specific day back, just not sure what I would
    | add to it to make it 2 specific days back (If you get what I'm saying)
    |
    | =TODAY()-WEEKDAY(TODAY()-6)
    |
    | Thanks,
    |
    | ~J
    |
    |
    | --
    | nbaj2k
    | ------------------------------------------------------------------------
    | nbaj2k's Profile: http://www.excelforum.com/member.php...o&userid=36480
    | View this thread: http://www.excelforum.com/showthread...hreadid=569940
    |



  11. #11
    Registered User
    Join Date
    07-18-2006
    Posts
    73
    wow, brain lapse, sorry about that, that makes complete sense not sure what I was thinking!

    Thanks for the help!

    ~J

  12. #12
    Registered User
    Join Date
    07-18-2006
    Posts
    73

    thanks! what about the previous week's Monday and Friday?

    One more thing, I have been using the formula, but I now want to use it a little differently. I have 2 cells next to each other, I want one to equal the past Monday, and the other to equal the previous Friday. The thing is I need them both to be part of the same week.

    For example, today is Thursday August 24th.

    I have the start day set to =TODAY()-WEEKDAY(TODAY()-2) and the end date set to =TODAY()-WEEKDAY(TODAY()-6)

    The problem with that is, there is a Monday in this week that went by so the range is, so the range is 8/21/06 to 8/18/06 which is not possible.

    Is there a way to do it for the complete week so that it would set it to the previous week's Monday and Friday?

    Sorry to reopen this!

    Thanks,

    ~J

  13. #13
    Registered User
    Join Date
    08-16-2006
    Posts
    11
    One more thing, I have been using the formula, but I now want to use it a little differently. I have 2 cells next to each other, I want one to equal the past Monday, and the other to equal the previous Friday. The thing is I need them both to be part of the same week.


    Assume the formula in b2=TODAY()-WEEKDAY(TODAY()-6)
    then a2 =b2-WEEKDAY(b2-2)

    this makes the a2 cell always be before the b2 cell

  14. #14
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Just make A2

    =B2-4

+ 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