Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Get Text Value of Dropdown

I have a dropdown on a worksheet which is populated programatically - I can
put the options into it fine, but I can't get them back out again.
I can get the .value or .listindex without a problem, but I'd rather be
working with the string.

I have been testing using the following:

Sub show_region()

Dim myDrop As Excel.DropDown
Set myDrop = Sheets("report").DropDowns("select_drop")
MsgBox myDrop.Text

End Sub

..Text comes up as a possible completion, but when I try to use it I get
"Unable to get the Text property of the DropDown class". Putting a watch on
myDrop while this is running indicates that the same is true for Caption,
which seemed the only other likely choice.

Can anyone tell me what I'm doing wrong here? Is it even possible to get a
string without having to go back and compare the index to the list originally
used to populate the dropdown?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Get Text Value of Dropdown

If you used a linked cell (on the same sheet or a different sheet), you could
have looked there.

Or...

Option Explicit
Sub show_region()

Dim myDrop As DropDown
Set myDrop = Sheets("report").DropDowns("select_drop")

With myDrop
If .ListIndex = 0 Then
MsgBox "Nothing selected"
Else
MsgBox .List(.ListIndex)
End If
End With

End Sub



Tara H wrote:

I have a dropdown on a worksheet which is populated programatically - I can
put the options into it fine, but I can't get them back out again.
I can get the .value or .listindex without a problem, but I'd rather be
working with the string.

I have been testing using the following:

Sub show_region()

Dim myDrop As Excel.DropDown
Set myDrop = Sheets("report").DropDowns("select_drop")
MsgBox myDrop.Text

End Sub

.Text comes up as a possible completion, but when I try to use it I get
"Unable to get the Text property of the DropDown class". Putting a watch on
myDrop while this is running indicates that the same is true for Caption,
which seemed the only other likely choice.

Can anyone tell me what I'm doing wrong here? Is it even possible to get a
string without having to go back and compare the index to the list originally
used to populate the dropdown?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Get Text Value of Dropdown

Thank you, that was exactly what I needed!

"Dave Peterson" wrote:

If you used a linked cell (on the same sheet or a different sheet), you could
have looked there.

Or...

Option Explicit
Sub show_region()

Dim myDrop As DropDown
Set myDrop = Sheets("report").DropDowns("select_drop")

With myDrop
If .ListIndex = 0 Then
MsgBox "Nothing selected"
Else
MsgBox .List(.ListIndex)
End If
End With

End Sub



Tara H wrote:

I have a dropdown on a worksheet which is populated programatically - I can
put the options into it fine, but I can't get them back out again.
I can get the .value or .listindex without a problem, but I'd rather be
working with the string.

I have been testing using the following:

Sub show_region()

Dim myDrop As Excel.DropDown
Set myDrop = Sheets("report").DropDowns("select_drop")
MsgBox myDrop.Text

End Sub

.Text comes up as a possible completion, but when I try to use it I get
"Unable to get the Text property of the DropDown class". Putting a watch on
myDrop while this is running indicates that the same is true for Caption,
which seemed the only other likely choice.

Can anyone tell me what I'm doing wrong here? Is it even possible to get a
string without having to go back and compare the index to the list originally
used to populate the dropdown?


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Get Text Value of Dropdown

Which version of excel?

I pasted your code in to a sheet module in Excel 2000. Pressing F1
returned the following:

Hidden Objects


Objects that have been hidden in the Microsoft Excel 97 Visual Basic
object model are listed in the following table. These objects are
supported only for backward compatibility; for new code, you should
use the replacement functionality provided in Microsoft Excel 97. To
view hidden objects in the Object Browser, right-click in the Object
Browser window and click Show Hidden Members on the shortcut menu. For
more information about the changes to the Microsoft Excel 97 object
model, see one of the following topics:


Hidden objects

Button, Buttons, CheckBox, CheckBoxes, DialogFrame, DropDown,
DropDowns, EditBox, EditBoxes, GroupBox, GroupBoxes, GroupObject,
GroupObjects, ListBox, ListBoxes, OptionButton, OptionButtons,
ScrollBar, ScrollBars, Spinner, Spinners, TextBox, TextBoxes

Replacement

ActiveX controls
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Changing Dropdown text color in a Combo Box. The SA guy Excel Discussion (Misc queries) 2 August 2nd 07 06:26 PM
How do I show a value for selected text from a dropdown list? Matt Excel Discussion (Misc queries) 2 January 4th 07 06:49 AM
Text, IF and dropdown function Pasty Excel Worksheet Functions 4 November 15th 06 03:30 PM
Excel dropdown with text and value mr. App Excel Worksheet Functions 2 December 27th 05 03:15 AM
Text Size in Dropdown Randy Vieira Excel Discussion (Misc queries) 1 January 26th 05 08:27 PM


All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"