+ Reply to Thread
Results 1 to 19 of 19

H Lookup error

  1. #1
    Registered User
    Join Date
    10-04-2005
    Posts
    73

    H Lookup error

    Hi All

    I am trying to use the following Hlookup however it is returning an error =HLOOKUP("=(DAY(TODAY())-1)",$D$74:$AH$111,6,FALSE)

    Please can someone help resolve this.

    Thank you

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: H Lookup error

    Are you actually looking for the string '=(DAY(TODAY())-1)' or do you want to look for the value returned by DAY(TODAY())-1?

    If it's the latter remove the "" and the second =.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-04-2005
    Posts
    73

    Re: H Lookup error

    Hi Norie

    This is excellent thank you.

    Just to complicate it slightly, can I amend the above formula to return a value for the last weekday i.e. weekend values are omitted?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: H Lookup error

    You would need a formula that would return the last weekday, and I'm afraid I don't have one.

    However I'm pretty sure if you searched the forum you would find one.

  5. #5
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: H Lookup error

    Hi Frus...
    Try this:-
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Change your Weekend days in the formula in place of 6 and 7..
    Untested Though...
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  6. #6
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: H Lookup error

    For weekend saturday
    Please Login or Register  to view this content.
    For weekend sunday
    Please Login or Register  to view this content.

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

    Re: H Lookup error

    So what is in the range D74:AH74? That's a 31 cell range, does it contain the numbers 1 to 31?What do you expect on 1st of the month when the previous workday is in the previous month?

    If you use =DAY(TODAY())-1 then on 1st of the month that returns zero - do you have zero in the lookup range?
    Audere est facere

  8. #8
    Registered User
    Join Date
    10-04-2005
    Posts
    73

    Re: H Lookup error

    Hi

    Apologies for the delay in replying.

    I have tried the formulas suggested but am not getting the desired result. Basically I would like the lookup to ignore the weekend completly.

    For example the look up value according to Norie's formula is Today (Monday 22nd) - 1 = lookup value of 21 however I would like to return a lookup value for the last weekday which is Friday i.e the 19th

    Thanks so far for your suggestions

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: H Lookup error

    Try this
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    10-04-2005
    Posts
    73

    Re: H Lookup error

    Hi kvsrinivasamurthy

    Thanks for your suggestion but I'm afraid that also did not work.

    I have attached a copy of the sheet I am using and entered your suggested H lookup formula in column C.

    To clarify:

    If today is a Monday, I would like the lookup to put in the previous Friday's data into column C
    If today is a Tuesday, I would like the lookup to put in the previous day's data (Monday) into column C
    If today is a Wednesday, I would like the lookup to put in the previous day's data (Tuesday) into column C
    If today is a Thursday, I would like the lookup to put in the previous day's data (Wednesday) into column C
    If today is a Friday, I would like the lookup to put in the previous day's data (Thursday) into column C
    If today is a Monday, I would like the lookup to put in the previous Friday's data into column C
    Etc Etc

    I am therefore looking to skip Saturdays and Sundays as data will only exist for a weekday


    Thank you for your continued efforts. I am sure someone can crack this for me!
    Attached Files Attached Files

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

    Re: H Lookup error

    You can use this formula in C4 copied down to get data for the previous workday

    =INDEX(D4:AH4,MATCH(DAY(WORKDAY(TODAY(),-1)),D$3:AH$3,0))

    Obviously today that will give you all zeroes because you don't have anything in the 22 column

    You didn't answer my question about previous months so I don't know whether that will work OK on 1st October......

  12. #12
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: H Lookup error

    Formula
    Please Login or Register  to view this content.

  13. #13
    Forum Expert
    Join Date
    03-28-2014
    Location
    Hyderabad,India
    MS-Off Ver
    Excel 2013
    Posts
    1,887

    Re: H Lookup error

    hI, TRY THIS

    =HLOOKUP(IF(TEXT(TODAY(),"ddd")="Sun",DAY(TODAY())-2,DAY(TODAY()-1)),$D$3:$AH$17,2,FALSE)

    PUNNAM

  14. #14
    Forum Expert boopathiraja's Avatar
    Join Date
    07-12-2013
    Location
    Coimbatore,TamilNadu, India
    MS-Off Ver
    Excel 2007, 2013, 2016, 365
    Posts
    1,455

    Re: H Lookup error

    May be try this

    =INDEX($D$1:$AH$17,ROW(),MATCH(DAY(WORKDAY(TODAY(),-1)),$D$3:$AH$3,0)
    Click just below left if it helps, Boo?ath?

  15. #15
    Forum Expert boopathiraja's Avatar
    Join Date
    07-12-2013
    Location
    Coimbatore,TamilNadu, India
    MS-Off Ver
    Excel 2007, 2013, 2016, 365
    Posts
    1,455

    Re: H Lookup error

    May be try this

    =INDEX($D$1:$AH$17,ROW(),MATCH(DAY(WORKDAY(TODAY(),-1)),$D$3:$AH$3,0)

  16. #16
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: H Lookup error

    Pl see attached file.
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: H Lookup error

    Pl see attached file.
    Attached Files Attached Files

  18. #18
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: H Lookup error

    For C4
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    10-04-2005
    Posts
    73

    Re: H Lookup error

    Hi All

    Thanks for the suggestions, the formulas provided all return the results required.

    In response to daddylonglegs' question - I do not require data for the previous day once a new month begins.

    Thanks everybody for your help. This can now be closed.

+ 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. [SOLVED] lookup error
    By lstevenson in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-10-2013, 12:51 AM
  2. [SOLVED] lookup - if(is error(vlookup and error messages meanings
    By grphillips in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-18-2013, 07:03 PM
  3. Lookup error
    By skonduru in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-25-2012, 01:39 PM
  4. Lookup Error #N/A
    By pansovic in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2010, 05:35 PM
  5. LOOKUP #N/A error
    By MatthewR in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-18-2008, 03:06 AM

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