Sir Babydum GBE
08-29-2007, 01:33 PM
Okay, I'm learning, but still finding it difficult to find info on certain userform stuff, so...
One
Say I have Frame1 & Frame2. There are three combo-boxes in each Frame.
I want Frame2 to be hidden (or greyed out) until Combo-box3 of Frame 1 is populated.
How do I do it?
Two
Same as above, but say I only want Frame 2 made visible if the user selects "yes" in Combo-box3 (of frame1)
Three
I have a combo-box named "cboAccType". If the user selects "Single", then another combo-box, "cboOffer", needs to look at named range "listDiscountSingle", whereas if the result of "cboAccType" was "Dual", then "cboOffer" needs to look at named range "listDiscountDual".
This is the code I have so far for initializing the Userform: Private Sub UserForm_Initialize()
Dim cAccType As Range
Dim cAttitude1 As Range
Dim cAttitude2 As Range
'Dim cDiscount As Range
Dim cElecMtr As Range
Dim cGasMtr As Range
Dim cOutcome As Range
Dim cCustTitle As Range
Dim ws As Worksheet
Set ws = Worksheets("Validations")
For Each cAccType In ws.Range("ListAccountType")
With Me.cboAccType
.AddItem cAccType.Value
.List(.ListCount - 1, 1) = cAccType.Offset(0, 1).Value
End With
Next cAccType
For Each cCustTitle In ws.Range("ListTitle")
With Me.cboTitle
.AddItem cCustTitle.Value
.List(.ListCount - 1, 1) = cCustTitle.Offset(0, 1).Value
End With
Next cCustTitle
For Each cAttitude1 In ws.Range("ListAttitude1")
With Me.cboDescribe1
.AddItem cAttitude1.Value
.List(.ListCount - 1, 1) = cAttitude1.Offset(0, 1).Value
End With
Next cAttitude1
For Each cAttitude2 In ws.Range("ListAttitude2")
With Me.cboDescribe2
.AddItem cAttitude2.Value
.List(.ListCount - 1, 1) = cAttitude2.Offset(0, 1).Value
End With
Next cAttitude2
For Each cElecMtr In ws.Range("ListElecMtr")
With Me.cboElecMtr
.AddItem cElecMtr.Value
.List(.ListCount - 1, 1) = cElecMtr.Offset(0, 1).Value
End With
Next cElecMtr
For Each cGasMtr In ws.Range("ListGasMtr")
With Me.cboGasMtr
.AddItem cGasMtr.Value
.List(.ListCount - 1, 1) = cGasMtr.Offset(0, 1).Value
End With
Next cGasMtr
For Each cOutcome In ws.Range("ListOutcome")
With Me.cboOutcome
.AddItem cOutcome.Value
.List(.ListCount - 1, 1) = cOutcome.Offset(0, 1).Value
End With
Next cOutcome
'For Each cDiscount In ws.Range("ListDiscountDual" 'or "ListDiscountSingle")
'With Me.cboOffer
'.AddItem cDiscount.Value
'.List(.ListCount - 1, 1) = cDiscount.Offset(0, 1).Value
'End With
'Next cDiscount
Me.txtAgent.Value = Environ("UserName")
End Sub
One
Say I have Frame1 & Frame2. There are three combo-boxes in each Frame.
I want Frame2 to be hidden (or greyed out) until Combo-box3 of Frame 1 is populated.
How do I do it?
Two
Same as above, but say I only want Frame 2 made visible if the user selects "yes" in Combo-box3 (of frame1)
Three
I have a combo-box named "cboAccType". If the user selects "Single", then another combo-box, "cboOffer", needs to look at named range "listDiscountSingle", whereas if the result of "cboAccType" was "Dual", then "cboOffer" needs to look at named range "listDiscountDual".
This is the code I have so far for initializing the Userform: Private Sub UserForm_Initialize()
Dim cAccType As Range
Dim cAttitude1 As Range
Dim cAttitude2 As Range
'Dim cDiscount As Range
Dim cElecMtr As Range
Dim cGasMtr As Range
Dim cOutcome As Range
Dim cCustTitle As Range
Dim ws As Worksheet
Set ws = Worksheets("Validations")
For Each cAccType In ws.Range("ListAccountType")
With Me.cboAccType
.AddItem cAccType.Value
.List(.ListCount - 1, 1) = cAccType.Offset(0, 1).Value
End With
Next cAccType
For Each cCustTitle In ws.Range("ListTitle")
With Me.cboTitle
.AddItem cCustTitle.Value
.List(.ListCount - 1, 1) = cCustTitle.Offset(0, 1).Value
End With
Next cCustTitle
For Each cAttitude1 In ws.Range("ListAttitude1")
With Me.cboDescribe1
.AddItem cAttitude1.Value
.List(.ListCount - 1, 1) = cAttitude1.Offset(0, 1).Value
End With
Next cAttitude1
For Each cAttitude2 In ws.Range("ListAttitude2")
With Me.cboDescribe2
.AddItem cAttitude2.Value
.List(.ListCount - 1, 1) = cAttitude2.Offset(0, 1).Value
End With
Next cAttitude2
For Each cElecMtr In ws.Range("ListElecMtr")
With Me.cboElecMtr
.AddItem cElecMtr.Value
.List(.ListCount - 1, 1) = cElecMtr.Offset(0, 1).Value
End With
Next cElecMtr
For Each cGasMtr In ws.Range("ListGasMtr")
With Me.cboGasMtr
.AddItem cGasMtr.Value
.List(.ListCount - 1, 1) = cGasMtr.Offset(0, 1).Value
End With
Next cGasMtr
For Each cOutcome In ws.Range("ListOutcome")
With Me.cboOutcome
.AddItem cOutcome.Value
.List(.ListCount - 1, 1) = cOutcome.Offset(0, 1).Value
End With
Next cOutcome
'For Each cDiscount In ws.Range("ListDiscountDual" 'or "ListDiscountSingle")
'With Me.cboOffer
'.AddItem cDiscount.Value
'.List(.ListCount - 1, 1) = cDiscount.Offset(0, 1).Value
'End With
'Next cDiscount
Me.txtAgent.Value = Environ("UserName")
End Sub