Lookup Column, MATCH, return row - do some two-way math based on MATCH

Joined
Feb 15, 2018
Messages
15
Hi folks,
I think I have a very complicated way of explaining something that should be rather simple, I think.

Background: My work offers credits. You earn credits after working 10 business days in a given month.

Worksheet: I created my work sheet so that Row 1 is equal to Day 1 of the month, etc. up to Row 31. Each month is 2 columns wide, starting with January in Columns D, and E. Using January as an example, I want to put that an employee started working January 2. In the spreadsheet I indicate this with the word START in E2, E being the 2nd column utilized for the month, cell 2 being the 2nd day of the month.

My problem:
I can calculate the credits using formulas, which is rather inefficient. But, also, I do not know how to formulate if there is a second condition. The second condition is the END date. In this example, lets use March 6. To indicate this I would use the word END in I6. I do not want to have to constantly use one formula or the other depending if START, or END is used.

The solution I need, based on the formulas I know, if there is a better solution, please offer it :
I want Excel to Check columns. E, G, I, etc. for either the word START or END
If found, what is the row - the row number indicates the day of the month
If START, calculate networkdays (excluding weekends, but holidays are ok and do not need to be exluded) from START day to end of month
If END, calculate networkdays from END to beginning of the month

If networkdays is greater than, or equal to 10 = 9.375

Also... if a month is between START and END = 9.375 (I have been doing this manually)

BONUS FEATURE:
Is there a way to identify NOTnetworkdays and to fill the cell with the colour black? if it can, it would also be cool to see "holidays" filled in some colour

Thank you :)
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
There is a much easier way to explain what you need,

The bonus feature could be done with conditional formatting and a rule something like =someday=WORKDAY(someday-1,1,holidays)

The rest of it will make more sense with the easier explanation.
 
Upvote 0
Hi Spaceballs_the_fanboy,

As Jason says it's difficult to interpret your requirements without some data and example results.

I've done the formatting for Holidays and weekends (using a grey background in case somebody overtypes) and identified the START and END rows for each month. Can you explain further?

Spaceballs_the_fan_boy.xlsx
DEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1HolidayDate
2StartNew Year1/1/2020
3Groundhog2/2/2020
4Bat Day4/3/2020
5Start
6Start
7End
8Start
9
10Start
11Start
12
13
14Start
15
16
17
18
19
20
21
22
23
24
25EndEndEnd
26
27End
28
29
30
31
32Jan-20Jan-20Feb-20Feb-20Mar-20Mar-20Apr-20Apr-20May-20May-20Jun-20Jun-20Jul-20Jul-20Aug-20Aug-20Sep-20Sep-20Oct-20Oct-20Nov-20Nov-20Dec-20Dec-20
33210514118611111
3472725302525313130313031
Sheet1
Cell Formulas
RangeFormula
F32,Z32,X32,V32,T32,R32,P32,N32,L32,J32,H32F32=E32+1
E32,AA32,Y32,W32,U32,S32,Q32,O32,M32,K32,I32,G32E32=EOMONTH(D32,0)
E33,AA33,Y33,W33,U33,S33,Q33,O33,M33,K33,I33,G33E33=IFERROR(MATCH("START",E$1:E$31,0),1)
E34,AA34,Y34,W34,U34,S34,Q34,O34,M34,K34,I34,G34E34=IFERROR(MATCH("End",E$1:E$31,0),DAY(E$32))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D1:AA31Expression=OR(TEXT(DATE(YEAR(D$32),MONTH(D$32),ROW()),"ddd")="Sat",TEXT(DATE(YEAR(D$32),MONTH(D$32),ROW()),"ddd")="Sun")textNO
D1:AA31Expression=INDEX($AF$2:$AF$99,MATCH(DATE(YEAR(D$32),MONTH(D$32),ROW()),$AF$2:$AF$99,0))textNO
 
Upvote 0
Thank you Jason, Toadstool... It definitely would be easier to see, than for me to explain - I appreciate you showing me how to share :)
Here is the worksheet I have. I have NOT applied Toadstools formula to it, just you can see what my issue was with my original post.
The text at the end of the forumlas is what I am wanting to do in a single formula, or VBA, or something more efficient than multiple formulas on multiple rows (like I have been doing).
Special note: Start and End will likely not be in the same month, sorry for that confusion.

Here's hoping the work I have done makes it easier to explain what I want :)

Cheers!

Leave Table - Zack (2).xlsx
ABCDEFGHIJKLMNOPQ
11
2TODAY2
3L2020-03-143
44
5E556004.500
6611007.500
7A7
88
9V9
1010START
11E11
1212
1313
1414
15B15
1616
17A1756000.250
1818
19L19
202011007.500
21A2156007.500
2222END
23N23
242498207.500
25C25
262698207.500
27E27
2828
29S29
3030
3131
32ForwardDAYJanuary-20February-20March-20April-20May-20June-20July-20
33Credit0.0009.3759.3759.3759.3750.0000.000
34VacationForwardDebit0.0000.00015.0000.0000.0000.0000.000
350.000Balance0.0009.3753.75013.12522.50022.50022.500
38Credits0.0009.3759.3759.3759.3759.3759.375
39Sick22000.0000.0000.0000.0000.0000.0000.000
40Forward21000.0000.0000.0000.0000.0000.0000.000
419.375Balance9.37518.75028.12518.75028.12537.50046.875
42Appt: Med / Dental53000.0000.0000.0000.0000.0000.0000.000
43Family RelatedAll0.0000.0000.0000.0000.0000.0000.000
44Personal day56000.0007.7504.5000.0000.0000.0000.000
45START START     
46END    END  
47
48FIRST DAY 2020-02-01  2020-05-01  
49DAY10  22  
50ACTUAL DATE2020-02-102020-05-22
51LAST DAY 2020-02-292020-05-31
52START or END?1921
53Look up Start, or End, and return the Row Number
54If Start - use date and count working days to end of month
55If End - use date and count working days from beginning of month to "end" date
56IF Start or End working days is >= 10 = 9.375, if <10 = ""
57
58
Sheet2
Cell Formulas
RangeFormula
B3B3=TODAY()
E34,Q34,O34,M34,K34,I34,G34E34=SUMIF(D$1:D$31,"1100",E$1:E$31)
E35,G35E35=SUM(B35+E33-E34)
G33G33=IF(OR(G1="START",G2="START",G3="START",G4="START",G5="START",G6="START",G7="START",G8="START",G9="START",G10="START",G11="START",G12="START",G13="START",G14="START",G15="START",G16="START",G17="START",G18="START",G19="START",G20="START",G21="START",G22="START",G23="START",G24="START",G25="START",G26="START",G27="START",G28="START",G29="START",G30="START",G31="START"),9.375,"")
I35,Q35,O35,M35,K35I35=SUM(G35+I33-I34)
E39,Q39,O39,M39,K39,I39,G39E39=SUMIF(D$1:D$31,$C$39,E$1:E$31)
E40,Q40,O40,M40,K40,I40,G40E40=SUMIF(D$1:D$31,$C$40,E$1:E$31)
E41E41=SUM(B41+E38-E39-E40)
E42,Q42,O42,M42,K42,I42,G42E42=SUMIF(D$1:D$31,$C$42,E$1:E$31)
E43,Q43,O43,M43,K43,I43,G43E43=E$96
E44,Q44,O44,M44,K44,I44,G44E44=E$91
E45,Q45,O45,M45,K45,I45,G45E45=IFERROR(VLOOKUP("START",E1:E31,1,FALSE),"")
E46,Q46,O46,M46,K46,I46,G46E46=IFERROR(VLOOKUP("END",E1:E31,1,FALSE),"")
G41,Q41,O41,M41,I41G41=SUM(E41+G38-G39-G40)
K41K41=SUM(B41+K38-K39-K40)
E48E48=IF($E$45="START",$D$32,IF($E$46="END",$D$32,""))
I48I48=IF($I$45="START",$H$32,IF($I$46="END",$H$32,""))
I49,G49,K49I49=IFERROR(MATCH(I45,I1:I31,0),"")
K48K48=IF($K$45="START",$J$32,IF($K$46="END",$J$32,""))
O48O48=IF($O$45="START",$N$32,IF($O$46="END",$N$32,""))
O49,Q49O49=IFERROR(MATCH(#REF!,#REF!,0),"")
Q48Q48=IF($Q$45="START",$P$32,IF($Q$46="END",$P$32,""))
G48G48=IF($G$45="START",$F$32,IF($G$46="END",$F$32,""))
G50,M50G50=G48+G49-1
G51,M51G51=EOMONTH(F32,0)
G52G52=G51-G50
M48M48=IF($M$45="START",$L$32,IF($M$46="END",$L$32,""))
M49M49=IFERROR(MATCH(M46,M1:M31,0),"")
M52M52=M50-M48
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E33,G33,E119,G119,I119,I33Cell Value>$K33textYES
U33,Y33,AA33,W33,K33,M33,O33,Q33,S33,M119,O119,Q119,S119,U119,W119,Y119,AA119Cell Value>$K33textYES
 
Upvote 0

Forum statistics

Threads
1,215,475
Messages
6,125,028
Members
449,205
Latest member
Eggy66

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