MsgBox advice for two different message options

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,923
Office Version
  1. 2007
Platform
  1. Windows
Morning.
I am using the code supplied below.
The issue i believe is with the code in Red.
The message concenred is in BLUE

This is used on a userform where making a selection from a ComboBox would then show two different selectable options BUT the message shown in BLUE below in shown for BOTH & ideally would like two different messages.

Example

If i select "TEST 1" from the ComboBox & i then see OptionButton1 & OptionButton3 appear.
If i now dont select either & try to continue i see the message shown in RED below.

If i select "TEST 2" from the ComboBox & i then see OptionButton2 & OptionButton4 appear.
If i now dont select either & try to continue i see the message shown in RED below.

So the same message shown for both cases, Ideally would be nice to see message YOU DID NOT SELECT EITHER OPTION 1 OR 3 & another message like YOU DID NOT SELECT EITHER OPTION 2 OR 4
So each have there own message
Rich (BB code):
Private Sub TransferButton_Click()
With ThisWorkbook.Worksheets("RANGER")
    Dim i As Long
    Dim x As Long
    Dim ctrl As Control
    Dim lastrow As Long

    Cancel = 0
    If TextBox1.Text = "" Then
        Cancel = 1
        MsgBox "NO CUSTOMER'S NAME WAS ENTERED", vbCritical, "RANGER FIELD EMPTY MESSAGE"
        TextBox1.SetFocus

    ElseIf TextBox2.Text = "" Then
        Cancel = 1
        MsgBox "YOU DIDNT ENTER THE VIN", vbCritical, "RANGER FIELD EMPTY MESSAGE"
        TextBox2.SetFocus

    ElseIf ComboBox1.Text = "" Then
        Cancel = 1
        MsgBox "NO YEAR WAS SELECTED", vbCritical, "RANGER FIELD EMPTY MESSAGE"
        ComboBox1.SetFocus

    ElseIf ComboBox2.Text = "" Then
        Cancel = 1
        MsgBox "REMOTE TYPE WAS NOT SELECTED", vbCritical, "RANGER FIELD EMPTY MESSAGE"
        ComboBox2.SetFocus
    End If

    If Cancel = 1 Then
        Exit Sub
    End If
    
    x = 0
    For i = 1 To 4
     If Me.Controls("OptionButton" & i) = True Then
     x = x + 1
     Opt = i
     End If
     
    Next
    If x = 0 Then
        MsgBox "YOU DIDNT SELECT AN OPTION BUTTON", vbCritical, "RANGER OPTION BUTTON EMPTY MESSAGE"
        Exit Sub
    End If

    Rows("5:5").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("B5:I5").Borders.LineStyle = xlContinuous
    Range("B5:I5").Borders.Weight = xlThin
    Range("B5:I5").Interior.ColorIndex = 6
    Range("C5:I5").HorizontalAlignment = xlCenter
    Sheets("RANGER").Range("B5").Select
    Cancel = 0
    
    If Cancel = 1 Then
        Exit Sub
        
    End If
    With ThisWorkbook.Worksheets("RANGER")
        .Range("B5").Value = TextBox1.Text
        .Range("D5").Value = TextBox2.Text
        .Range("F5").Value = TextBox3.Text
        .Range("G5").Value = TextBox4.Text
        .Range("C5").Value = ComboBox1.Text
        .Range("H5").Value = ComboBox2.Text
        .Range("E5").Value = Me.Controls("OptionButton" & Opt).Caption
    End With
        
    If ComboBox2.Value = "ORIGINAL 2B" Then

 Unload RangerFormRemote
 RangerPcbNumber.Show
    
 Else
    With .Range("I5")
        .Value = "N/A"
        .Font.Size = 14
        .Font.Name = "Calibri"
        .Font.Bold = True
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlVAlignCenter
        Unload RangerFormRemote
     End With

    With Sheets("RANGER")
        If .AutoFilterMode Then .AutoFilterMode = False
        x = .Cells(.Rows.Count, 5).End(xlUp).Row
        .Range("A4:I" & x).Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlGuess
        MsgBox "DATABASE UPDATED SUCCESSFULLY", vbInformation, "SUCCESSFUL MESSAGE"
    End With
        Application.ScreenUpdating = True
    Range("B6").Select
    Range("B5").Select
    End If
 End With
 
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Watch MrExcel Video

Forum statistics

Threads
1,129,383
Messages
5,635,951
Members
416,889
Latest member
dhegs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top