+ Reply to Thread
Results 1 to 2 of 2

If statement in if statement.. Input box

Hybrid View

christopherL If statement in if... 10-23-2013, 11:22 AM
AB33 Re: If statement in if... 10-23-2013, 11:26 AM
  1. #1
    Registered User
    Join Date
    10-11-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2002
    Posts
    71

    If statement in if statement.. Input box

    Hi there, I tried to make a nested if statement that recognizes an input box..
    I am having some trouble with the next statement it seems.

    Anyone that can find out the problem for this?

    
    Sub CheckFrequency()
    
    Dim input_box As Integer
    
    input_box = InputBox("What should frequency be higher than?")
    
        For m = 5 To 20
            If input_box = "5" Then
                If Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
                
            ElseIf input_box = "4" Then
                If Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
                
            ElseIf input_box = "3" Then
                If Range("E" & m).Value > 0 Or Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
                
            ElseIf input_box = "2" Then
                If Range("D" & m).Value > 0 Or Range("E" & m).Value > 0 Or Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
                    
            ElseIf input_box = "1" Then
                If Range("C" & m).Value > 0 Or Range("D" & m).Value > 0 Or Range("E" & m).Value > 0 Or Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
           
            End If
         Next
    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If statement in if statement.. Input box

    Sub CheckFrequency()
    
    Dim input_box As Integer
    
    input_box = InputBox("What should frequency be higher than?")
    
        For m = 5 To 20
            If input_box = "5" Then
                If Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
                End If
            ElseIf input_box = "4" Then
                If Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
                End If
            ElseIf input_box = "3" Then
                If Range("E" & m).Value > 0 Or Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
                End If
            ElseIf input_box = "2" Then
                If Range("D" & m).Value > 0 Or Range("E" & m).Value > 0 Or Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
                End If
            ElseIf input_box = "1" Then
                If Range("C" & m).Value > 0 Or Range("D" & m).Value > 0 Or Range("E" & m).Value > 0 Or Range("F" & m).Value > 0 Then
                    Range("G" & m).Interior.ColorIndex = 7
                End If
            End If
         Next
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macros to input formaulas into a lot of cells. Formula has an IF statement
    By stylecrazy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2013, 04:22 PM
  2. How to select from Multiple Input Charts/Graphs with If statement?
    By jespvik in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-26-2013, 11:28 AM
  3. How do you input user defined variables into an AutoFilter statement?
    By trhoades in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-14-2010, 11:26 PM
  4. Compare user input with range (with an if statement)
    By HBF in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2008, 11:35 AM
  5. Using a Input Box Value in an if statement
    By Vick in forum Excel General
    Replies: 4
    Last Post: 06-08-2006, 05:30 PM

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