New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

Nested If(AND)/Select case

Macros, VBA, Excel Automation, etc.

Nested If(AND)/Select case

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

Hello,

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

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

Return to Macros and VBA Questions

Who is online

Users browsing this forum: Google [Bot] and 52 guests

cron