jammer6_9
01-22-2009, 11:14 AM
I was wondering how and why this code works. All I thought is if there is "If" it must be closed by "End If"... On the code below, I have written 5 "If" and closed only with 2 "End If" that I don't understand. Please :help me understand...
Private Sub cmdGo_Click()
On Error Resume Next
If cmbMarket.Value = "" Or cmbtrend.Value = "" Or cmbIN.Value = "" Then
MsgBox ("All fields required, Fill up all to continue!"), vbExclamation, "ofsjcr"
If cmbMarket.Value = "" Then cmbMarket.SetFocus
If cmbtrend.Value = "" Then cmbtrend.SetFocus
If cmbIN.Value = "" Then cmbIN.SetFocus
Else
If cmbMarket.Value = "KSA" And cmbtrend.Value = "SALES COMPS" And cmbIN.Value = "NUMBERS" Then
Sheets("GRAPH SALES KSA").Visible = True
Sheets("GRAPH SALES KSA").Select
Else
ThisWorkbook.Sheets("GRAPH SALES KSA").Visible = xlSheetVeryHidden
End If
Unload Me
End If
End Sub
Private Sub cmdGo_Click()
On Error Resume Next
If cmbMarket.Value = "" Or cmbtrend.Value = "" Or cmbIN.Value = "" Then
MsgBox ("All fields required, Fill up all to continue!"), vbExclamation, "ofsjcr"
If cmbMarket.Value = "" Then cmbMarket.SetFocus
If cmbtrend.Value = "" Then cmbtrend.SetFocus
If cmbIN.Value = "" Then cmbIN.SetFocus
Else
If cmbMarket.Value = "KSA" And cmbtrend.Value = "SALES COMPS" And cmbIN.Value = "NUMBERS" Then
Sheets("GRAPH SALES KSA").Visible = True
Sheets("GRAPH SALES KSA").Select
Else
ThisWorkbook.Sheets("GRAPH SALES KSA").Visible = xlSheetVeryHidden
End If
Unload Me
End If
End Sub