LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default HELP!! VBA Nested IF Function

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I do a TODAY() Function within a Nested IF AND Function Jennifer E Excel Discussion (Misc queries) 1 April 11th 10 12:15 PM
Nested IF function mrl Excel Worksheet Functions 3 April 15th 08 10:52 PM
can you nested sum and round function within if function? anna Excel Worksheet Functions 4 May 27th 06 06:06 AM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM
Nested IF Function, Date Comparing, and NetworkDays Function carl Excel Worksheet Functions 2 December 29th 04 09:57 PM


All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"