SOLVED

How to assign hidden values to specific text in my dropdown data validation that is later sum

%3CLINGO-SUB%20id%3D%22lingo-sub-1921527%22%20slang%3D%22en-US%22%3EHow%20to%20assign%20hidden%20values%20to%20specific%20text%20in%20my%20dropdown%20data%20validation%20that%20is%20later%20sum%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1921527%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20to%20assign%20hidden%20values%20to%20specific%20text%20in%20my%20dropdown%20data%20validation%20that%20is%20later%20sum.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20been%20trying%20to%20figure%20out%20a%20solution%20to%20the%20above%20where%20I%20can%20create%20a%20work%20schedule%20that%20when%20I%20add%20a%20work%20shift%20code%2C%20for%20example%20S1%2C%20then%20it%20would%20be%20representing%208%20hours%20of%20scheduled%20work%20hours%20and%20S2%20to%20represent%204%20hours%20of%20scheduled%20work%20then%20when%20I%20total%20the%202%20cells%20then%20I'm%20suppose%20to%20get%2012%20hours.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20know%20how%20to%20create%20the%20drop%20down%2C%20just%20don't%20know%20how%20to%20assign%20the%20hours%20to%20each%20work%20shift%20so%20when%20I'm%20summing%20those%20cells%20it%20is%20read%20as%20numbers%20even%20though%20text%20is%20visible.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1921527%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1921568%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20assign%20hidden%20values%20to%20specific%20text%20in%20my%20dropdown%20data%20validation%20that%20is%20later%20sum%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1921568%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F877811%22%20target%3D%22_blank%22%3E%40kirkBolton%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECreate%20a%20small%20lookup%20table.%20In%20the%20screenshot%20below%2C%20it%20is%20in%20E2.%3AF3.%3C%2FP%3E%0A%3CP%3EE2%3AE3%20can%20serve%20as%20source%20list%20for%20data%20validation.%3C%2FP%3E%0A%3CP%3ELet's%20say%20you%20have%20entered%20Shift%20Codes%20in%20B2%3AB6.%3C%2FP%3E%0A%3CP%3EThe%20total%20number%20of%20hours%20corresponding%20to%20these%20codes%20is%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DSUMPRODUCT(LOOKUP(B2%3AB6%2C%24E%242%3A%24E%243%2C%24F%242%3A%24F%243))%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22S0003.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F235448i60F99CC953428506%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22S0003.png%22%20alt%3D%22S0003.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%E2%80%83%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1922161%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20assign%20hidden%20values%20to%20specific%20text%20in%20my%20dropdown%20data%20validation%20that%20is%20later%20sum%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1922161%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20response%20Hans.%3C%2FP%3E%3CP%3EYour%20solution%20should%20work%20if%20only%20I%20know%20how%20to%20do%26nbsp%3Bshift%20codes.%20Please%20explain%20further.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20thanks.%3C%2FP%3E%3CP%3EKirk%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1922164%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20assign%20hidden%20values%20to%20specific%20text%20in%20my%20dropdown%20data%20validation%20that%20is%20later%20sum%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1922164%22%20slang%3D%22en-US%22%3Elol%2C%20Apologies%20Han%2C%20just%20realized%20the%20shift%20codes%20are%20the%20same%20S1%20etc%20that%20I%20referred%20to%20in%20the%20beginning.%20Scrap%20that%20earlier%20response%20let%20me%20try%20applying%20the%20formula%20u%20sent.%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1938681%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20assign%20hidden%20values%20to%20specific%20text%20in%20my%20dropdown%20data%20validation%20that%20is%20later%20sum%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1938681%22%20slang%3D%22en-US%22%3EGreetings%20Hans%2C%20thanks%20again%20for%20the%20solution.%20I'm%20now%20realizing%20that%20some%20of%20the%20assigned%20cells%20are%20not%20giving%20the%20results.%20So%20some%20works%20and%20some%20doesn't.%20Do%20you%20know%20what%20might%20be%20causing%20this.%20Maybe%20I%20can%20send%20you%20the%20form%20to%20look%20at.%20I'm%20going%20to%20send%20you%20the%20file.%20The%20results%20are%20not%20posting%20for%20some%20of%20my%20staff%20codes%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1938931%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20assign%20hidden%20values%20to%20specific%20text%20in%20my%20dropdown%20data%20validation%20that%20is%20later%20sum%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1938931%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F877811%22%20target%3D%22_blank%22%3E%40kirkBolton%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYour%20schedule%20is%20completely%20empty%2C%20so%20it's%20no%20wonder%20that%20there%20is%20no%20result.%3C%2FP%3E%0A%3CP%3EBut%20the%20formula%20that%20I%20provided%20assumed%20that%20all%20days%20have%20been%20filled%20in.%20The%20following%20version%20(again%20confirmed%20with%20Ctrl%2BShift%2BEnter)%20handles%20blanks%20too%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMPRODUCT(IFERROR(LOOKUP(E6%3AK6%2C%24AD%244%3A%24AD%2417%2C%24AE%244%3A%24AE%2417)%2C0))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20can%20be%20filled%20down.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

How to assign hidden values to specific text in my dropdown data validation that is later sum. 

 

I have been trying to figure out a solution to the above where I can create a work schedule that when I add a work shift code, for example S1, then it would be representing 8 hours of scheduled work hours and S2 to represent 4 hours of scheduled work then when I total the 2 cells then I'm suppose to get 12 hours.

 

I know how to create the drop down, just don't know how to assign the hours to each work shift so when I'm summing those cells it is read as numbers even though text is visible.

 

Thanks

10 Replies

@kirkBolton 

Create a small lookup table. In the screenshot below, it is in E2.:F3.

E2:E3 can serve as source list for data validation.

Let's say you have entered Shift Codes in B2:B6.

The total number of hours corresponding to these codes is

 

=SUMPRODUCT(LOOKUP(B2:B6,$E$2:$E$3,$F$2:$F$3))

 

S0003.png

@Hans Vogelaar 

 

Thanks for your response Hans.

Your solution should work if only I know how to do shift codes. Please explain further.

 

With thanks.

Kirk

lol, Apologies Han, just realized the shift codes are the same S1 etc that I referred to in the beginning. Scrap that earlier response let me try applying the formula u sent.
Greetings Hans, thanks again for the solution. I'm now realizing that some of the assigned cells are not giving the results. So some works and some doesn't. Do you know what might be causing this. Maybe I can send you the form to look at. I'm going to send you the file. The results are not posting for some of my staff codes

@kirkBolton 

Your schedule is completely empty, so it's no wonder that there is no result.

But the formula that I provided assumed that all days have been filled in. The following version (again confirmed with Ctrl+Shift+Enter) handles blanks too:

 

=SUMPRODUCT(IFERROR(LOOKUP(E6:K6,$AD$4:$AD$17,$AE$4:$AE$17),0))

 

This can be filled down.

Hi Hans, thanks for your feedback. I accidentally sent you a blank form. Please find attached a copy of the form using both the initial formula you provided and your most recent formula. Your most recent formula is used in the yellow highlighted cells. I am not getting the results of the shift code value using the new formula you provided. In blue highlight is the use of your initial formula but it's not giving the correct corresponding value for the shift code.  I would greatly appreciate your assistance in resolving this issue. I can't understand why the values for the corresponding shift code is giving a different result. 

 

THANKS AGAIN.

@kirkBolton 

When LOOKUP is used to return multiple results, the lookup_vector (or array) argument must be sorted in ascending order. Thus, the formula in K5 in the attached version of your file is:

=SUMPRODUCT(LOOKUP(D5:J5,$AB$4:$AC$22))

@Twifoo 

Thanks for your input, Robert. The suggestion still didn't fix my problem. Is there any other option you can suggest.

Best Response confirmed by kirkBolton (Occasional Contributor)
Solution

@kirkBolton I'm not sure why that isn't working for you because when I opened it the numbers appear correctly.  Please note that what @Twifoo did was rearrange your lookup table to be in alpha-numerically increasing order (e.g. S1 then S10, ..., S14, then S2  because '1' is before '2' so 'S1...' is before 'S2...').  That said, here are 2 alternative suggestions you could try:

If you have XLOOKUP() I suggest using it:

=SUMPRODUCT(XLOOKUP(D6:J6,$AB$4:$AB$22,$AC$4:$AC$22,0,0))

 You could also use INDEX-MATCH combination to force an exact match (I added the IFERROR just in case but since you have data validation you could remove that)

=SUMPRODUCT(INDEX($AC$4:$AC$22,IFERROR(MATCH(D7:J7,$AB$4:$AB$22,0),1)))

 

@mtarler 

 

Your solution using =SUMPRODUCT(XLOOKUP(D28:J28,$AB$4:$AB$22,$AC$4:$AC$22,0,0)) worked perfect. 

 

Thank you and thanks to everyone. I have learnt so much from the community. I am so grateful for this resource and the skills of you guys. Thanks