• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Combobox with 4 items

S P P

Member
If it is empty, the 4 items will appear
If I choose A from the list, I can only switch to B
If I choose C from the list I can only change it to D
If you clear the cambobox it will display the 4 items.
 

Attachments

  • SPP Combobox with 4 items.xlsm
    21.1 KB · Views: 1
Code:
Private Sub ComboBox1_Change()
Select Case ComboBox1.Value
Case "A"
  ComboBox1.List = Array("B")
Case "B"
  ComboBox1.List = Array("A")
Case "C"
  ComboBox1.List = Array("D")
Case "D"
  ComboBox1.List = Array("C")
Case ""
  ComboBox1.List = Array("A", "B", "C", "D")
End Select
End Sub
 
Data Validation

In a spreadsheet

How would it be

With the same conditions as the Form

Use this code

Data Validation

In a spreadsheet

How would it be

With the same conditions as the Form

Use this code

Data Validation

In a spreadsheet

How would it be

With the same conditions as the Form

>>> use code - tags <<<
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B:B")) Is Nothing Then
For Each Cll In Intersect(Target, Range("B:B"))
    Select Case Cll.Value
    Case "A"
       Cll.Interior.ColorIndex = 3
    Case "C"
       Cll.Interior.ColorIndex = 4
    Case "B", "D"
       Cll.Interior.ColorIndex = 24
    Case ""
       Cll.Interior.ColorIndex = xlNone
End Select
Next Cll
End If
End Sub
 
Last edited by a moderator:
Back
Top