if combobox.value is x then y problem

DB73

Board Regular
Joined
Jun 7, 2022
Messages
102
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2010
  6. 2007
Platform
  1. Windows
  2. Mobile
  3. Web
Hi all,

Maybe stupid question, but why is this not working 🤨
cant the combobox read the value as text ??

thanks in advance

VBA Code:
Private Sub ComboBox2_Change()

    If (ComboBox2.value = "alleen rit registratie") Then
 
        'werklocatie
             ComboBox3.Enabled = False
             ComboBox3.value = "-"
             ComboBox3.BackColor = RGB(210, 210, 210)
        'BTW verlegd ja/nee
            ComboBox9.Enabled = False
            ComboBox9.value = "-"
            ComboBox9.BackColor = RGB(210, 210, 210)
             
    Else
        'project
             ComboBox3.Enabled = True
             ComboBox3.value = ""
             ComboBox3.BackColor = RGB(255, 255, 255)
        'BTW verlegd ja/nee
            ComboBox9.Enabled = True
            ComboBox9.value = ""
            ComboBox9.BackColor = RGB(255, 255, 255)
        
        End If
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Are you sure the code goes in combobox2?
The text "alleen rit registratie" is correct?
Should it be lowercase?

Try this:

Rich (BB code):
Private Sub ComboBox2_Change()
  If UCase(ComboBox2.Value) = UCase("alleen rit registratie") Then
    'werklocatie
    ComboBox3.Enabled = False
    ComboBox3.Value = "-"
    ComboBox3.BackColor = RGB(210, 210, 210)
    'BTW verlegd ja/nee
    ComboBox9.Enabled = False
    ComboBox9.Value = "-"
    ComboBox9.BackColor = RGB(210, 210, 210)
  Else
    'project
    ComboBox3.Enabled = True
    ComboBox3.Value = ""
    ComboBox3.BackColor = RGB(255, 255, 255)
    'BTW verlegd ja/nee
    ComboBox9.Enabled = True
    ComboBox9.Value = ""
    ComboBox9.BackColor = RGB(255, 255, 255)
  End If
End Sub
 
Upvote 0
Solution
Are you sure the code goes in combobox2?
The text "alleen rit registratie" is correct?
Should it be lowercase?

Try this:

Rich (BB code):
Private Sub ComboBox2_Change()
  If UCase(ComboBox2.Value) = UCase("alleen rit registratie") Then
    'werklocatie
    ComboBox3.Enabled = False
    ComboBox3.Value = "-"
    ComboBox3.BackColor = RGB(210, 210, 210)
    'BTW verlegd ja/nee
    ComboBox9.Enabled = False
    ComboBox9.Value = "-"
    ComboBox9.BackColor = RGB(210, 210, 210)
  Else
    'project
    ComboBox3.Enabled = True
    ComboBox3.Value = ""
    ComboBox3.BackColor = RGB(255, 255, 255)
    'BTW verlegd ja/nee
    ComboBox9.Enabled = True
    ComboBox9.Value = ""
    ComboBox9.BackColor = RGB(255, 255, 255)
  End If
End Sub
thanks...how stupid i could be...it was about that uppercase😜


thanks anyway...solved
 
Upvote 0

Forum statistics

Threads
1,215,094
Messages
6,123,071
Members
449,092
Latest member
ipruravindra

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
Back
Top