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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
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,213,510
Messages
6,114,034
Members
448,543
Latest member
MartinLarkin

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