Multiple IIF statements in an expression

HeatherBrian

New Member
Joined
Oct 26, 2004
Messages
23
I am trying to create an IIF statement that takes multiple items into account. I am able to write each if statement separately but an not sure how to combine them. I want both IIF statements to be under the expression actor. I need the following information to be returned. If Test1S is No than Factor is null; however, if Test1S is yes and Worksheet-General Information is yes than 75 otherwise 100. The purpose of this is to score different sections of an exam. If they do not need to complete Test1S than they should not receive any credit; however, if they have to complete they will either receive 100 (if no mistakes) or 75 (if mistakes).

Any help would be greatly appreciated.

Thanks.


Factor: IIf([Worksheet-General Information]=Yes And [Test1S]=Yes,75,100)


Factor1: IIf([Test1S]=No,Null)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
if Test1S is No than Factor is null
if Test1S is yes and Worksheet-General Information is yes than 75
otherwise 100

sounds like you need a nested if:

Factor: IIf([Test1S]=No, null, iif([Worksheet-General Information]=Yes,75,100))

hth,
Giacomo
 
Upvote 0
It would be much easier and clearer to read your SQL if you just built a custom function to insert into the SQL.

As a limited explanation, when writing a code module, you can specify parameters to be passed to it. So what you do is something like:

Code:
SELECT functionNameHere([fieldname1],[fieldname2]) FROM tblName

Public Function functionNameHere(ByVal fld1 As String, ByVal fld2 As String) As String

' put code here to work with the contents of the two variables passed
' to it and then return a result by setting it equal to the function name
' using a code module lets you do things like embed if...then...else
' or Select Case statements

functionNameHere = whatever_you_want

End Function

Mike
 
Upvote 0

Forum statistics

Threads
1,213,507
Messages
6,114,029
Members
448,543
Latest member
MartinLarkin

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