Using If command or better solution?

martyp

Board Regular
Joined
Apr 12, 2006
Messages
61
Hi all,
Please can someone suggest the best way of doing the below.

3 shift patterns determined by number (values 1,2,3)
Each one has a time assigned for different breaks etc. (e.g. shift 1 break 1030-1040, shift 2 break 1050-1100).

I'm probably being really thick here but I tried using the IF function as below to get the output according to what the value was in cell A2 (shift) but it doesn't work?
=IF(A2=1,"1030-1040",""), IF(A2=2,"1050-1100","")

Sorry, it's probably a really simple query but if someone could advise what I'm doing wrong I'd really appreciate it. I know IF is really useful so I'm trying to get my head round using it properly.

Of course, if there's a better function to use I'd be interested to know.

Many thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
3 shift patterns determined by number (values 1,2,3)
Each one has a time assigned for different breaks etc. (e.g. shift 1 break 1030-1040, shift 2 break 1050-1100).

What is the break for shift 3? If there is no break for shift 3 the formula would be:

=IF(A2=0,"",IF(A2=1,"1030-1040",IF(A2=2,"1050-1100",IF(A2=3,""))))

If the break for shift 3 is something like "1140-1150", formula would be:

=IF(A2=0,"",IF(A2=1,"1030-1040",IF(A2=2,"1050-1100",IF(A2=3,"1140-1150"))))
 
Upvote 0
Many thanks VoG, although I can't seem to get that to work in my version of Excel (2000). Is it for a later version?

I actually just realised I had to nest the If function correctly to get it to work:
=IF(A2=1,"1030-1040",IF(A2=2,"1050-1100",IF(A2=3,"1110-1120")))

Not sure if that's the best method of doing it or not?
 
Upvote 0
Thanks doofusboy, that works nicely. It's always a comma or bracket or something I tend to end up missing causing it to not work. I'll have to make sure I remember the more common Excel formulas like IF as it would definitely make things easier I think. :)
 
Upvote 0
Sorry, could I maybe just ask one other thing...

I'm doing another spreadsheet and am trying to devise a formula where by if the value in column A equals todays date it would be the value in another cell (say G5), if it is in advance of todays date then it would be say E4-e3, if it's earlier than today's date it would be a blank cell?

Can anyone advise at all?

(last one for now I promise!) :)
 
Upvote 0

Forum statistics

Threads
1,224,509
Messages
6,179,192
Members
452,893
Latest member
denay

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