C
chad.carmichael
I am trying to create a VB function with a nested if statement. I
know how to do this in Excel but I have 16 different options I need to
choose from and Excel of course limits you at 7. Here is the code I
have written so far. The d10, l10 etc are the cell numbers in excel.
My problem is when I put this in excel, it doesn't recognize the
numerical values in the spreadsheet from each cell so it always says
Unkown Bank instead of the 16 listed banks to choose from. The way
it's setup now, D96 is the correct answer, but I'm not getting
anywhere.
Any help!?!
Function CalcValue(pVal As String)
If pVal = D10 Then
CalcValue = A10
ElseIf pVal = L10 Then
CalcValue = I10
ElseIf pVal = D36 Then
CalcValue = A36
ElseIf pVal = L36 Then
CalcValue = I36
ElseIf pVal = D70 Then
CalcValue = A70
ElseIf pVal = L70 Then
CalcValue = I70
ElseIf pVal = D96 Then
CalcValue = A96
ElseIf pVal = L96 Then
CalcValue = I96
ElseIf pVal = D130 Then
CalcValue = A130
ElseIf pVal = L130 Then
CalcValue = I130
ElseIf pVal = D156 Then
CalcValue = A156
ElseIf pVal = L156 Then
CalcValue = I156
ElseIf pVal = D190 Then
CalcValue = A190
ElseIf pVal = L190 Then
CalcValue = I190
ElseIf pVal = D216 Then
CalcValue = A216
ElseIf pVal = L216 Then
CalcValue = I216
Else
CalcValue = "Unknown Bank"
End If
End Function
know how to do this in Excel but I have 16 different options I need to
choose from and Excel of course limits you at 7. Here is the code I
have written so far. The d10, l10 etc are the cell numbers in excel.
My problem is when I put this in excel, it doesn't recognize the
numerical values in the spreadsheet from each cell so it always says
Unkown Bank instead of the 16 listed banks to choose from. The way
it's setup now, D96 is the correct answer, but I'm not getting
anywhere.
Any help!?!
Function CalcValue(pVal As String)
If pVal = D10 Then
CalcValue = A10
ElseIf pVal = L10 Then
CalcValue = I10
ElseIf pVal = D36 Then
CalcValue = A36
ElseIf pVal = L36 Then
CalcValue = I36
ElseIf pVal = D70 Then
CalcValue = A70
ElseIf pVal = L70 Then
CalcValue = I70
ElseIf pVal = D96 Then
CalcValue = A96
ElseIf pVal = L96 Then
CalcValue = I96
ElseIf pVal = D130 Then
CalcValue = A130
ElseIf pVal = L130 Then
CalcValue = I130
ElseIf pVal = D156 Then
CalcValue = A156
ElseIf pVal = L156 Then
CalcValue = I156
ElseIf pVal = D190 Then
CalcValue = A190
ElseIf pVal = L190 Then
CalcValue = I190
ElseIf pVal = D216 Then
CalcValue = A216
ElseIf pVal = L216 Then
CalcValue = I216
Else
CalcValue = "Unknown Bank"
End If
End Function