Hi all,
I'm trying to create a code for cell G20 (see attached workbook), which represents a value for "intercept". This "intercept" value changes, depending on multiple conditions, which is why I need to write a complex nesting IF function with multiple AND conditions to get the correct value. Currently, I have only six nesting IFs, but eventually I will need 963. I am just testing this out to see if I can get six going and then I will worry about the remaining 957 lol.
So here is my code to accomplish this:
and my workbook is attached here:Sub IfThenNesting()
If C3 = "CCI" And C5 = "Case-Shiller National Home Price Index" And C9 = 5 Then Range("I4").Value
End If
ElseIf C3 = "CCI" And C5 = "National Unemployment Rate" And C9 = 0 Then Range("I5").Value
End If
ElseIf C3 = "CCI" And C5 = "S&P 500 Stock Prices" And C9 = 0 Then Range("I6").Value
End If
ElseIf C3 = "CCI" And C5 = "# of House Units Starts" And C9 = 3 Then Range("I7").Value
End If
ElseIf C3 = "National Unemployment Rate" And C5 = "S&P 500 Stock Prices" And C9 = 0 Then Range("I8").Value
End If
ElseIf C3 = "S&P 500 Stock Prices" And C5 = "Nordstrom Stock Price" And C9 = 0 Then Range("I9").Value
End If
End Sub
VBA IF test.xlsx
I want to do a nesting IF statement with multiple conditions. It all makes sense if you look at the worksheet. I want the calculation of the IF statement to be entered into cell G20.
Any help is GREATLY appreciated on getting me started. THANK YOU.
Bookmarks