V/Hlookup or Index/Match assistance Required?

godzilla65

Board Regular
Joined
Nov 25, 2004
Messages
125
Hi Team,

I am struggling with the following formula, hoping someone can steer me towards a solution.

In the Workbook I have a Worksheet Called “Hours Data”, in column B5:B500 I have Dates which are essentially the Months Jan-2012 up to Dec-2024, In row C4:T4, I have a list of companies eg Company A, Company B etc, and for each month we place the total work ours for the month against each company in corresponding cell – This is the source data.

I have another worksheet Company-Stats where I am failing to come up with a formula that I can get working as follows:

In Cell C3 I have a listbox that has all the Company names, Column C6:C500 is the start of the Month Date eg 01/09/2024, Colum D6:D500 I have the End of Month date eg 30/09/2024, and in column E is where I am failing in my formula.

The formula sounds simple, but I am running into a blank wall, I just wish to select the company form Cell 3, and for every month it populates the hours if the date falls within the start and end dates, for that specific company selected from the data list “Hours Data”

Start Date | End Date | Total Work Hours

01/07/24 31/07/24 36,1234

01/08/24 31/08/24 45,527

01/09/204 30/09/24 25,122

Any help on a formula appreciated!!

Cheers Eric
 

Attachments

  • Data Worksheet.JPG
    Data Worksheet.JPG
    52.5 KB · Views: 10
  • Results.JPG
    Results.JPG
    67.7 KB · Views: 9

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
how are the dates formatted in the data sheet - only showing month and year
is that the 1st of the month formatted
OR text

if the date in the data sheet are all 1st month
and the results are all for complete months and start is always 1st month
then a grid lookup should work

what version of excel

i'll mock up and use the grid lookup
EDIT using a grid lookup

does assume the dates are in the correct format


=INDEX(Sheet1!$D$3:$F$5,MATCH(Sheet2!A4,Sheet1!$C$3:$C$5,0),MATCH(Sheet2!$A$1,Sheet1!$D$1:$F$1,0))

Book3
ABCDEF
1company 1company 2company 3
2
31-Aug-24101001100
41-Sep-24111101200
51-Oct-24121201300
6
Sheet1
Cells with Data Validation
CellAllowCriteria
A1Timebetween 00:00:00 and 23:59:00


Book3
ABC
1company 1
2
3
48/1/248/31/2410
59/1/249/30/2411
610/1/2410/31/2412
Sheet2
Cell Formulas
RangeFormula
B4:B6B4=EOMONTH(A4,0)
C4:C6C4=INDEX(Sheet1!$D$3:$F$5,MATCH(Sheet2!A4,Sheet1!$C$3:$C$5,0),MATCH(Sheet2!$A$1,Sheet1!$D$1:$F$1,0))
 
Upvote 0
Howdy etaf,

Yes, the dates in the data sheet are all the 1st of the month and formatted, and running on 365 - Microsoft® Excel® for Microsoft 365 MSO (Version 2408 Build 16.0.17928.20114) 64-bit

That would be appreciated as I am stumped.

Cheers Eric
 
Upvote 0
Try,. In E7 of Sheet2, copied to full column.
Excel Formula:
=IFERROR(INDEX(Sheet1!$D$3:$K$1000,MATCH($C7,Sheet1!$A$3:$A$1000,0),MATCH($C$4,$D$2:$K$2,0)),"")
 
Upvote 0
then the formula I posted modified to match your sheet names and ranges should work OK

Also

kvsrinivasamurthy

looks the same sort of thing, BUT if it cannot find a match you get an blank cell rather than an error message

it would be worth putting the 365 version in you profile
helps with solutions - as loads of different functions and newer functions in the later version
 
Upvote 0
as you are using 365 version then you could use xlookup
=XLOOKUP(A4,Sheet1!$C$3:$C$5,XLOOKUP($A$1,Sheet1!$D$1:$F$1,Sheet1!$D$3:$F$5))

then with an error handling, you can show which element is not being found , also i think it maybe faster performance wise (2 functions v 3 in basic formula0 - but probably not noticeable

=IFERROR(XLOOKUP(A4,Sheet1!$C$3:$C$5,XLOOKUP($A$1,Sheet1!$D$1:$F$1,Sheet1!$D$3:$F$5),"Date Not found"),"Company Not found")
 
Upvote 0
as you are using 365 version then you could use xlookup
=XLOOKUP(A4,Sheet1!$C$3:$C$5,XLOOKUP($A$1,Sheet1!$D$1:$F$1,Sheet1!$D$3:$F$5))

then with an error handling, you can show which element is not being found , also i think it maybe faster performance wise (2 functions v 3 in basic formula0 - but probably not noticeable

=IFERROR(XLOOKUP(A4,Sheet1!$C$3:$C$5,XLOOKUP($A$1,Sheet1!$D$1:$F$1,Sheet1!$D$3:$F$5),"Date Not found"),"Company Not found")


Thanks heaps - been awhile since I posted, prior to 365 that is for sure, let me process the formula's and revert if I am having any issues - thanks all.
 
Upvote 0

Forum statistics

Threads
1,224,737
Messages
6,180,653
Members
452,992
Latest member
TokugawaIesuma

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top