Select name in dropdown

Ramachandran

New Member
Joined
Oct 17, 2011
Messages
47
If I want to get the (string) value of the select item in the dropdown, that's allright:
With Worksheets("Registrering").Shapes("Drop Down 1").ControlFormat
name = .List(.Value)
End With

But I want to go the other way, selecting the listindex from the string value,
If I do this:

With Worksheets("Registrering").Shapes("Drop Down 1").ControlFormat
.List(.Value) = namn
End With
I will overwrite listindex = 1...
 

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
If I run the last code, the drop down(Forms Combobox) will show the name.value, but it will overwrite whatever the previous selected value was.
The name.value is already added to the dropdown, I simply want to programmatically select it.
Anyone who can help?
 
Upvote 0
With Worksheets("Registrering").Shapes("Drop Down 1").ControlFormat
i = 0
Do
i = i + 1
Loop Until .List(i) = name Or i = .ListCount
.ListIndex = i
End With

This works, so I'm happy. But please do let me know if there is any other solution.
 
Upvote 0
like this:
Code:
With Worksheets("Registrering").DropDowns("drop down 1")   
    .Value = Application.Match(name, .List, 0)
End With
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,639
Members
449,093
Latest member
Ahmad123098

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