Find value in combobox by Target.Value

drag1c

Board Regular
Joined
Aug 7, 2019
Messages
97
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hi,

I am using event Worksheet Before Double Click, where I double click on cell to open form.
Form is filled by data from row, where the cell was double clicked.

In Form exists ComboBox with specific values, for example:
1) Low
2) Medium
3) High
4) None

I wish to create something like this but it will not work:
Code:
.Combobox1 = Target.Offset(0,-5)

How I can get value from cell in that combobox, but to not change list structure of the combobox?
If list structure is {Low, Medium, High, None}, this code below will create {Low, Medium, High, None, Medium} and set Medium as value inside combobox...
Code:
.cmbArea.AddItem Target.Offset(0, -3)
.cmbArea.Text = .cmbArea.List(.cmbArea.ListCount - 1)

1686750095564.png

So, Idea would be to somehow find value which already exists in combobox and to place it as predefined value.

Do you have an idea how it could be done?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I take it that if the userform control value is already in the combo list (and the combo is on a sheet) then you want to use that userform control value. If not, you want to add it or do something else? To find out if a value is in a sheet combo list, something like this will tell you:
VBA Code:
For i = 0 To ComboBox2.ListCount - 1
     If ComboBox2.List(i) = "0" Then MsgBox "found it"
Next
Then you can simply use an If block to either set the combo to the existing value if found, or add the item if that's what you want to do.
You'd probably replace 0 with Target.Offset(0,-5)
Note that I'm not really suggesting you use a msgbox; it's just an example.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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