Results 1 to 7 of 7

Trying to understand IF Else Statements

Threaded View

  1. #1
    Forum Contributor
    Join Date
    01-08-2013
    Location
    Jacksonville, Fl
    MS-Off Ver
    Excel 2016
    Posts
    355

    Trying to understand IF Else Statements

    Hello,

    Can someone take a look at some basic code I wrote and help me figure out what i'm doing wrong.

    I would like for a person to enter 2 colors (red, blue or yellow) to make a new color.

    If they choose any other color they get an error.

    Sub colorMix()
    
    Dim color1 As String
    Dim color2 As String
    
    color1 = InputBox("Enter the first color")
    color2 = InputBox("Enter the second color")
    
    If Not color1 = "Red" Then
        MsgBox ("You can only enter Red, Blue, or Yellow")
    End If
    
    If Not color1 = "Blue" Then
        MsgBox ("You can only enter Red, Blue, or Yellow")
    End If
    
    If Not color1 = "Yellow" Then
        MsgBox ("You can only enter Red, Blue, or Yellow")
    End If
    
    If Not color2 = "Red" Then
        MsgBox ("You can only enter Red, Blue, or Yellow")
    End If
    
    If Not color2 = "Blue" Then
        MsgBox ("You can only enter Red, Blue, or Yellow")
    End If
    
    If Not color2 = "Yellow" Then
        MsgBox ("You can only enter Red, Blue, or Yellow")
    End If
    
    If Color = "Red" And color2 = "Blue" Then
        MsgBox ("The new color is Purple")
    
    Else
    
    If color1 = "Red" And color2 = "Yellow" Then
       MsgBox ("The new color is orange")
    
    Else
    
    If color1 = "Blue" And color2 = "Yellow" Then
       MsgBox ("The new color is Green")
    
    End If
    End If
    End If
    End Sub
    Thank you very much
    Last edited by Justair07; 10-09-2013 at 08:20 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. what does 6.9544E+23 stand for?
    By gokarterid in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-30-2012, 11:50 AM
  2. Let the gurus stand up please
    By abambam in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2011, 12:54 PM
  3. Stand Alone program
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2007, 10:47 AM
  4. What does the ! stand for in formulas?
    By ! in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-14-2005, 05:06 PM
  5. [SOLVED] Stand alone
    By Khalil Handal in forum Excel General
    Replies: 1
    Last Post: 03-08-2005, 07:06 AM

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