Results 1 to 4 of 4

Nested IF loops More than 7 Need Help

Threaded View

  1. #1
    Registered User
    Join Date
    07-30-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    20

    Nested IF loops More than 7 Need Help

    Hello All,

    So ive got a pull down menu in a cell. Depending on what item is selected from the pull down menu a constant intager will be multiplied by another user input integer in a seperate cell. the result will be reported in another cell. For example.

    If the user selects "3 Inch Binder" and then reports they need 3 of them. The system must calculate that each binder is 1 dollar. thus it will report 3 dollars.

    Now if they select "5 inch Binder" and again report they need 3, the system must now use the constant 1.50 per binder. and thus report the total as 4.50.

    I can do this easily with nested IF loops, but i have 10 items on my list, meaning i need to use VBA.

    This is my code so far....what am i doing wrong?




    Function Tabs(Val As String, Quan As Integer)
    
        If Val = "1 Tab Bank of 5" Then
            Tabs = Quan * 2.5
            
        ElseIf Val = "2 Tab Banks of 5" Then
            Tabs = Quan * 5
            
        ElseIf Val = "3 Tab Banks of 5" Then
            Tabs = Quan * 7.5
            
        ElseIf Val = "4 Tab Banks of 5" Then
            Tabs = Quan * 10
        
        ElseIf Val = "5 Tab Banks of 5" Then
            Tabs = Quan * 12.5
            
        ElseIf Val = "6 Tab Banks of 5" Then
            Tabs = Quan * 15
            
        ElseIf Val = "7 Tab Banks of 5" Then
            Tabs = Quan * 17.5
            
        ElseIf Val = "8 Tab Banks of 5" Then
            Tabs = Quan * 20
            
        ElseIf Val = "9 Tab Banks of 5" Then
            Tabs = Quan * 22.5
            
        ElseIf Val = "10 Tab Banks of 5" Then
            Tabs = Quan * 25
        
        Else
            Tabs = 0
        End If
    End Function
    This isnt working at all however.

    Any Ideas? ( I have proper indention in the code itself.)

    NOTE: Quan will be the user input for how many of the item they need. The constants being multiplied in the code correspond to the price per unit for that item. Hence why Quan is multiplied by the price per unit to give us the final amount to be reported in the cell where the formula is called.
    Last edited by Leith Ross; 07-31-2013 at 02:44 PM. Reason: Added Code Tagas

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. nested loops
    By short_n_curly in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2012, 11:10 AM
  2. Nested loops VBA
    By zurich in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2012, 03:21 PM
  3. Nested Loops
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2009, 04:14 PM
  4. [SOLVED] Many Nested loops
    By naterator in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2006, 05:45 PM
  5. [SOLVED] nested loops
    By jer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2006, 05:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1