Change activeX combo box values depending on cell value

brendalpzm

Board Regular
Joined
Oct 3, 2022
Messages
58
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
Platform
  1. Windows
Hello everyone~

I have a problem with a task that I'm not sure how to do it.

I have an excel file where I make quotations and it brings a total quotation at the end. According to that quotation result I have an ActiveX combo box that should bring a specific range of values, for example:

Sheet1 name : DB
1664973079043.png


Sheet2 name : Quotation

Quotation total cell: C4

Logic:

If quotation is >= 200 then ComboBox1 brings platinum values
If quotation is >= 500 then ComboBox1 brings gold values
If quotation is >= 800 then ComboBox1 brings diamond values

I'm not sure how to do it, maybe with vba?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Put the following code in the events of the sheet "Quotation"

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Count > 1 Then Exit Sub
  Dim lr As Long
  Dim db As Worksheet
  Set db = Sheets("DB")
  
  If Target.Address = "$C$4" Then
    With ComboBox1
      Select Case Target.Value
        Case Is >= 800: .ListFillRange = db.Name & "!C2:C" & db.Range("C" & Rows.Count).End(3).Row
        Case Is >= 500: .ListFillRange = db.Name & "!B2:B" & db.Range("B" & Rows.Count).End(3).Row
        Case Is >= 200: .ListFillRange = db.Name & "!A2:A" & db.Range("A" & Rows.Count).End(3).Row
      End Select
    End With
  End If
End Sub

SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.

The above is assuming that in cell C4 you write a value, if it is a formula then I need to do another solution, similar, because everything changes if it is a formula.

Note: What happens if the value is less than 200?
 
Upvote 0

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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