Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Set dropdown programatically

Hi,

I know how to read from a toolbar dropdown

Range("Value") = CommandBars("MyBar").Controls("myDropDown").Text

But suppose I change Range("Value") in some other way (e.g. in a sub) and
want to synchronize the toolbar with the value in the cell. Can I do so
programatically?

Thanks!

Bura


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Set dropdown programatically

Hi Bura,

I know how to read from a toolbar dropdown

Range("Value") = CommandBars("MyBar").Controls("myDropDown").Text

But suppose I change Range("Value") in some other way (e.g. in a sub) and
want to synchronize the toolbar with the value in the cell. Can I do so
programatically?


use a ComboBox instead a DropDown Control:

With Application.CommandBars.Add("MyBar", Temporary:=True)
With .Controls.Add(msoControlComboBox)
.Caption = "myComboBox"
' ...
' ...


Application.CommandBars("MyBar").Controls("myCombo Box").Text = _
Range("Value").Value

--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Set dropdown programatically


"Melanie Breden" wrote in message
...
Hi Bura,

I know how to read from a toolbar dropdown

Range("Value") = CommandBars("MyBar").Controls("myDropDown").Text

But suppose I change Range("Value") in some other way (e.g. in a sub)

and
want to synchronize the toolbar with the value in the cell. Can I do so
programatically?


use a ComboBox instead a DropDown Control:

With Application.CommandBars.Add("MyBar", Temporary:=True)
With .Controls.Add(msoControlComboBox)
.Caption = "myComboBox"
' ...
' ...

Think you, I will try this!

Application.CommandBars("MyBar").Controls("myCombo Box").Text = _
Range("Value").Value

--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Set dropdown programatically

"Melanie Breden" wrote in message ...
Hi Bura,

I know how to read from a toolbar dropdown

Range("Value") = CommandBars("MyBar").Controls("myDropDown").Text

But suppose I change Range("Value") in some other way (e.g. in a sub) and
want to synchronize the toolbar with the value in the cell. Can I do so
programatically?


use a ComboBox instead a DropDown Control:

With Application.CommandBars.Add("MyBar", Temporary:=True)
With .Controls.Add(msoControlComboBox)
.Caption = "myComboBox"
' ...
' ...


Application.CommandBars("MyBar").Controls("myCombo Box").Text = _
Range("Value").Value


Hmmm. I still get "Invalid procedure call or argument".

(What's the difference between a drop down and a combo box?)
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Set dropdown programatically

I have commandbar examples on my website

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bura Tino" wrote in message
...
Hi,

I know how to read from a toolbar dropdown

Range("Value") = CommandBars("MyBar").Controls("myDropDown").Text

But suppose I change Range("Value") in some other way (e.g. in a sub) and
want to synchronize the toolbar with the value in the cell. Can I do so
programatically?

Thanks!

Bura






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Set dropdown programatically

Hi,

Bura Tino wrote:
Application.CommandBars("MyBar").Controls("myCombo Box").Text = _
Range("Value").Value


Hmmm. I still get "Invalid procedure call or argument".


in which line stops the debugger?
Here is the complete Code, (tested from XL97 to XL2003 with Win XP):

Sub DropDownBar()
On Error Resume Next
Application.CommandBars("MyBar").Delete
On Error GoTo 0

With Application.CommandBars.Add("MyBar", Temporary:=True)
With .Controls.Add(msoControlComboBox)
.Caption = "myComboBox"
.AddItem "A"
.AddItem "B"
.AddItem "C"
.OnAction = "ComboValue"
End With
.Visible = True
End With
End Sub

Sub ComboValue()
Range("Value") = CommandBars("MyBar").Controls("myComboBox").Text
End Sub

Sub SetDropDownValue()
Application.CommandBars("MyBar").Controls("myCombo Box").Text = _
Range("Value").Value
End Sub

(What's the difference between a drop down and a combo box?)

It´s impossible to show an entry/value in a dropdown control with using VBA.
You have to use a comboBox.

--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)

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
Dropdown box display only data dependent on another dropdown box? Chris Excel Worksheet Functions 8 August 5th 08 05:01 PM
How to programatically control a 3D-sum? Ake Excel Worksheet Functions 6 February 2nd 06 09:20 AM
offer dropdown options based on another dropdown Conor Excel Discussion (Misc queries) 2 January 13th 06 04:28 PM
Programatically set ref to my DLL ricks Excel Programming 2 April 13th 04 03:08 PM
Altering UI Programatically Alan Greenwood Excel Programming 2 November 1st 03 05:43 PM


All times are GMT +1. The time now is 12:45 PM.

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"