Premium Excel Course Now Available!

Build Professional - Unbreakable - Forms in Excel

45 Tutorials - 5+ Hours - Downloadable Excel Files

Instant Access! - Lifetime Access!
View Course

Nested If(AND)/Select case

Macros, VBA, Excel Automation, etc.
Forum rules
This forum is closed.

All new posts should be made at our new Excel Forum at

Nested If(AND)/Select case

Postby Latrell_k » Mon Jan 23, 2017 7:16 am


I'm been trying to write a VBA code for the following excel formula:

=IF(AND(A2="Vectrus",Q2="US"),1,IF(AND(A2="Vectrus",Q2<>"US"),2,IF(AND(A2="MSS",Q2="US"),3,IF(AND(A2="MSS",Q2<>"US"),4,IF(AND(A2="Stanley",Q2="US"),5,IF(AND(A2="Dav Force",Q2="US"),6,IF(AND(A2="Dav Force",Q2<>"US"),7,IF(AND(A2="MIGTC",Q2<>"US"),8,IF(AND(A2="KRH",Q2<>"US"),9,10)))))))))

Could some please assist me with writing either a select case or nested IF(And) VBA code. I tried recording a macro typing with code but after I went to run the macro I received a Debug error.
  • 0

Posts: 1
Joined: Jan 23, 2017
Reputation: 0
Excel Version: 2013

Return to Macros and VBA Questions

Who is online

Users browsing this forum: No registered users and 1 guest