3 conditions in an IF statement - VBA

aragorn179

New Member
Joined
Nov 29, 2012
Messages
7
I want to create a VBA function that returns an answer based off three different conditions. I was going to write an IF function but was wondering how to incorporate the three different columns in excel into the function. For example would I write something along the lines of:
If A > 2 and B > 2 and C > 2 Then
D = X
elseif A > 2 and B < 2 and C > 2 Then
D = y
Else D = z
Endif
I just need some help writing the three column values in to return different conditions based on those values.
Thankyou
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Something like

For example using cells in the first row

Code:
if cells(1,"A")>2 and cells(1,"B")>2 and cells(1,"C")>2 then
......
End if

Or
Code:
If range("A1")>2 and range("B1")>2 and range(c1")>2 then
....
End  if
 
Upvote 0

Forum statistics

Threads
1,224,163
Messages
6,176,789
Members
452,743
Latest member
Unique65

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