If Elseif else statement

vijaycs

New Member
Joined
Aug 17, 2019
Messages
8
How to write a VBA code to get the below output. Thanks

If Column A = AAA , Column C = XXX , Column E = YYY Then column F = Yes
If Column A = BBB , Column C = XXX , Column E = YYY Then column F = Yes
If Column A = ZZZ , Column C = XXX , Column E = YYY Then column F = Yes
and if Column A is anything else then , Column F = None
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Code:
Sub vijaycs()
'Assumes data starts in A1 - change to suit
Dim Lr As Long
Lr = Range("A:E").Find("*", , , , , xlPrevious).Row
Application.ScreenUpdating = False
With Range("F1:F" & Lr)
    .Formula = "=IF(OR(A1="""",C1="""",E1=""""),""None"",IF(AND(OR(A1=""AAA"",A1=""BBB"",A1=""ZZZ""),C1=""XXX"",E1=""YYY""),""Yes"",""None""))"
    .Value = .Value
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks Joe.
However if the I had the below request

If Column A = Internal, Then column F = ok and
If Column C = Long or Short Then column F = ok
and if Column A is anything else, then it should check if Column C = Long or Short if yes then column F = ok else column F = check.

Thank you in Advance
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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