if and formula

wereman

New Member
Joined
Dec 29, 2007
Messages
18
I'm a teacher making a school timetable and my problem is that there are three teachers in Grade 1 and two classrooms which means that one is always free. How can I write a formula to determin which one is free.
If Monday first period has Ms White in class 1 and Ms Blue in class 2 and Ms Green is therefore free. The problem is further complicated by the fact that each teacher teaches two subjects and they teach it to both classes.

HELP!!!!:(
 
Dear RalphA

Thanks for your feedback. It's much easier to understand than the other post that I got (please HOTPEPPER, don't feel offended - not necessarily better, just simpler for my simple mind to understand)

Below see what I've done with your formuli. It's colour coded for you to keep track with what i'm trying to achieve. and for all intents, I have achieved it. But for one snag: the IF, AND and OR option only allows 7 options but as you can see, in Year 1, for example, not only do they need ENGLLISH, MATHS, SCIENCE, SPANISH and SOCIALES, there's also DRAMA, ART, MUSIC, IT, SPANISH HELPER, ENGLISH HELPER and at least two PHYSICAL EDUCATION options. Any ideas??:confused:<br>
timetable 2008.xls
BCDEFGHIJK
1MondayTuesdayWednesdayThursdayFriday
2RegistrationRegistrationRegistrationRegistrationRegistration
3
4          
5
6          
7
8          
9
10          
11
12          
13
14          
2008 Master Timetable
<br><br><br>
timetable 2008.xls
MNOPQRSTU
1Year 1Year 2Year 3
2Susan MVickyGabySilvina SClaudia MCaroMaggieLizAlex
3EnglishEnglishSpanishSpanishSpanishEnglishEnglishEnglishSpanish
4MathsMathsSocialesSocialesSocialesScienceScienceScienceSociales
5ScienceScienceMathsMathsMathsMaths
6Year 4Year 5Year 6
7MoiraSilvina KClaudia SEugeniaAraceliJohnDougalDanielaMabel
8EnglishMathsSpanishMathsSpanishEnglishEnglishMathsSpanish
9ScienceSocialesSocialesScienceScienceSociales
10Special teachers
11DramaArtMusicITSp HelpEng HelpD-body
12XXXPaulinaSusan PBobbyGracielaYYYMelina
13Physical Education
14Pablo****MarianoDiegoPanchoPaulaLorenaCristinaMaru
2008 Master Timetable
 
Last edited:
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Wereman:

Hotpepper's solution is, undoubtedly, much better than mine, which makes use of nested IFs, something that is not usually accepted as good codeing practice by the programming community.

However, I, as you, am more confortable with the simpler and easier to understand code that uses IFs. And, I am happy to hear from you that you could take my formulas and achieve your goals...with the often expressed problem of "running out of IFs"!

The trick with neste IFs is this: Only seven nested IFs and one "parent" IF are allowed in one statement. But, you may concatenate up to thirty groups of these eight Ifs! Here's an example, using 12 total IFs:

=IF(A=1,A,IF(A=2,B,IF(A=3,C,IF(A=4,D,IF(A=5,E,IF(A=6,F,IF(A=7,G,IF(A=8,H,""))))))))&IF(A=9,I,IF(A=10,J,IF(A=11,K,IF(A=12,L,"")

Notice that if all the IFs in any group fail, it is imperitive to have the last result to be a blank, the "".

I hope this will suffice to allow you to complete your project successfully.
 
Upvote 0
Dear RalpA
Thanks again for all your help. My project is coming along very nicely now. I have another (related) question:
Up until now most subjects are taught by single teachers which makes the allocation of time and place to each relatively easy (as your help proved). But now I have a situation in Grade 4 where both classes are taught at the same time by four teachers (Drama, Art, Music and IT - what I've called DAMIT). What I now want to do is write into my formula something like:
=if(A1="DAMIT",merge A1 with B1 and also concatenate A2 with B2 where the teacher names now read $AB$3 &" , " & $AC$3 &" , " & $AD$3 &" , "& $AE$3
Or something to that effect. Maybe I'll need a macro for this, right?:eek:
 
Upvote 0
Wereman:

I think that, as soon as a formula starts to get complicated, especially if due to repetive parts, it is probably time to look for a VBA solution. Me, I'm hardheaded (persistant, I call it), and think VBA is too complicated for me. So, I try to obtain a formula type solution; if it seems out of the question, I just give up, and try method of presenting the problem. Let me give this a try, for your four teachers, each of whom teach two subjects.

Calling the teachers t1, t2, t3, and t4, and the subjects, d, a, m, and i, let's begin by forming some tables:

aa1=t1: ab1=d:ac1=a
aa2=t2: ab2=a:ac2=m
aa3=t3: ab3=m:ac1=i
aa4=t4: ab4=i:ac2=d

After merging the groups of two consecutive cells, the formula to use would be something like this, for a the subjects in two consecutive cells, say, in cells B4 and B5:

=if(or(and(B4=$ab$1,B5=$ac$1),and(B4=$ab$2,B5=$ac$2),and(B4=$ab$3,B5=$ac$3),$aa$4,
if(or(and(B4=$ab$2,B5=$ac$2),and(B4=$ab$3,B5=$ac$3),and(B4=$ab$4,B5=$ac$4),$aa$1,
if(or(and(B4=$ab$3,B5=$ac$3),and(B4=$ab$4,B5=$ac$4),and(B4=$ab$1,B5=$ac$1),$aa$2,
if(or(and(B4=$ab$4,B5=$ac$4),and(B4=$ab$1,B5=$ac$1),andB4=$ab$2,B5=$ac$2),$aa$3,""))))

Note that one builds up the formula, writing the first and(), copying it three times, and overwriting what is necessary, then copying the first IF four times, and proceeding to overwrite the old values that change, which is fairly easy. Now, one can copy this formula across, in the merged cells. Done
 
Upvote 0

Forum statistics

Threads
1,221,607
Messages
6,160,792
Members
451,671
Latest member
kkeller10

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