How to add different (hours/minutes) to a cell when choosing an item from the dropdown list

excelstudentnl

New Member
Joined
Sep 12, 2022
Messages
6
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
ok, so it basically comes down to making an excel sheet with the hours/minutes spend cleaning machines.
I've made a dropdown list in excel "B2" with 5 items (machines)

Cell B2 = (dropdown list) machine 1, machine 2, machine 3, machine 4, machine 5.

Cell B5 = contains the Start (at what time cleaning started) example: 01-01-2022 14:20 "I use 24hours instead of AM/PM"
Cell B6 = contains the End ( which adds 16 hours to the start date "we have 16 or 24 hours MAX to spend on a cleaning a specific machine"
so in Cell B6 my formula =
Excel Formula:
=B5+16/24

the problem however is:
machines 1 to 3 = have 16 hours max to spend on cleaning
but machines 4 & 5 = have 24 hours max to spend on cleaning


So now my question is, how can I make the dropdown list so that Machine 1 to 3 adds the formula : B5+16/24 to Cell B6
And if I choose Machine 4 or 5 it adds the formula: B5+24/24 to Cell B6

I don't have alot of experience with excel, I'm guessing I got to work with the =IF formula to make this work
or perhaps use a totally different approach? =IF(B2="Machine 3",B6= ........? )
I hope somebody can help me or atleast point me in the right direction

Thankyou in advance!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
you can use a IF () or a lookup table

=B1+TIME(16,0,0)
or for 24hours
=B1+1
where B1 is the starttime

very simple
Book1
ABCD
1machine 110/6/22 7:1510/6/22 23:15
2machine 210/7/22 7:1510/7/22 23:15
3machine 310/8/22 7:1510/8/22 23:15
4machine 410/9/22 7:1510/10/22 7:15
5machine 510/10/22 7:1510/11/22 7:15
6machine 610/11/22 7:1510/11/22 23:15
Sheet1
Cell Formulas
RangeFormula
D1:D6D1=IF(OR(A1="machine 4",A1="machine 5"),B1+1,B1+TIME(16,0,0))


but defaults to 16 hours - we can fix that to , i assume you can only have machine 1 to 5 in the dropdown
but is this the sort of thing

or a table if things are going to change and use a lookup - which again we can add - if thats the case - rather than inside hardcoded to a formula
 
Upvote 0
Solution
you can use a IF () or a lookup table

=B1+TIME(16,0,0)
or for 24hours
=B1+1
where B1 is the starttime

very simple
Book1
ABCD
1machine 110/6/22 7:1510/6/22 23:15
2machine 210/7/22 7:1510/7/22 23:15
3machine 310/8/22 7:1510/8/22 23:15
4machine 410/9/22 7:1510/10/22 7:15
5machine 510/10/22 7:1510/11/22 7:15
6machine 610/11/22 7:1510/11/22 23:15
Sheet1
Cell Formulas
RangeFormula
D1:D6D1=IF(OR(A1="machine 4",A1="machine 5"),B1+1,B1+TIME(16,0,0))


but defaults to 16 hours - we can fix that to , i assume you can only have machine 1 to 5 in the dropdown
but is this the sort of thing

or a table if things are going to change and use a lookup - which again we can add - if thats the case - rather than inside hardcoded to a formula
Thankyou for your quick answer!
the only thing I don't understand is that you used the cells as: machine 1,2,3 etc.
but i have a dropdown list so I have no cells (no columns/rows) to link as you have shown in your example

B1 = is the dropdown list
B5 = START date
B6 = END date (+16 or 24 hours)

test1.png
 
Upvote 0
that was just an example of the different possible results - so you can see , without a dropdown and how different dropdown values would result

B1 = is the dropdown list
B5 = START date
B6 = END date (+16 or 24 hours)

in B6 put
=IF(OR(B1="machine 4",B1="machine 5"),B5+1,B5+TIME(16,0,0))
 
Upvote 0
you can use a IF () or a lookup table

=B1+TIME(16,0,0)
or for 24hours
=B1+1
where B1 is the starttime

very simple
Book1
ABCD
1machine 110/6/22 7:1510/6/22 23:15
2machine 210/7/22 7:1510/7/22 23:15
3machine 310/8/22 7:1510/8/22 23:15
4machine 410/9/22 7:1510/10/22 7:15
5machine 510/10/22 7:1510/11/22 7:15
6machine 610/11/22 7:1510/11/22 23:15
Sheet1
Cell Formulas
RangeFormula
D1:D6D1=IF(OR(A1="machine 4",A1="machine 5"),B1+1,B1+TIME(16,0,0))


but defaults to 16 hours - we can fix that to , i assume you can only have machine 1 to 5 in the dropdown
but is this the sort of thing

or a table if things are going to change and use a lookup - which again we can add - if thats the case - rather than inside hardcoded to a formula

Thankyou! it works, the only problem is that it only adds 24hours to: Machine 5.
Machine 4 stays at 16hours but it also need to be 24hours.

I had to translate the formulas to dutch but I used the same formula u explained:

(dutch) =ALS(OF(B1="machine 4";B1="machine 5");B5+1;B5+TIJD(16;0;0))
"we have to use ; instead of , in order for formulas to work.

(english) =IF(OR(B1="machine 4",B1="machine 5"),B5+1,B5+TIME(16,0,0))

do you know how to solve this perhaps?
 
Upvote 0
is the dropdown with
Machine 5
actually machine 5
and no spaces - like
Machine 5<space>
Or
<space> machine 5
Or
machine5
no space between the word or number

in a cell try
B1="machine 5"
Will be FALSE until you change the dropdown - when you select machine 5 - does the cell show TRUE
 
Upvote 0
is the dropdown with
Machine 5
actually machine 5
and no spaces - like
Machine 5<space>
Or
<space> machine 5
Or
machine5
no space between the word or number

in a cell try
B1="machine 5"
Will be FALSE until you change the dropdown - when you select machine 5 - does the cell show TRUE

there was indeed a <space> after the word: Machine 4 (rookie mistake haha)
Thank you so much for your help! this solved my problem
Sorry for my late response btw, my working day was just finished when I got the reply yesterday!
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,126
Members
453,021
Latest member
Justyna P

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