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
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,210
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 

vijaycs

New Member
Joined
Aug 17, 2019
Messages
8
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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,009
Messages
5,526,258
Members
409,689
Latest member
martin_br

This Week's Hot Topics

Top