View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default ActiveX ComboBox Linked Cell

Ronald,
Here's an exercise you can try to help you understand how to work with
and manipulate a combobox (or any other control) you create on a
worksheet.

Open a new workbook and on Sheet1 create a combobox over cells C3:D4.

Create a list of numeric values (10,20,30,40,50) in A1:A5.

While in DesignMode:
Right-click the combobox;
Open its Properties window from the popup menu;
Set its 'ListFillRange' to A1:A5, close the window, exit DesignMode.

Right-click the sheet tab and open the code module behind Sheet1.
Maximize the window so it fills the code pane.

In the left side dropdown at the top of the code window, select
ComboBox1. This will create its _Change event sub. Enter the code I
posted earlier for this event.

Normalize the VBE window so you can see the worksheet behind it.

Make sure the Immediate Window is open below the code window. (Hit
Ctrl+G)

In the Immediate Window:

Type...
Sheet1.ComboBox1.Text="20"
Observe what happens on the worksheet.

Type...
Sheets("Sheet1").ComboBox1.Text="30"
Observe what happens on the worksheet.

In the worksheet:
Select a value from the combobox dropdown
Observe what happens on the worksheet.

Back in the VBE:
Insert a module into the workbook, and paste the follow procedure into
its code window.

Option Explicit

Sub TestCombobox()
Sheet1.ComboBox1.Text = "50"
Sheets("Sheet1").ComboBox1.Text = "20"
End Sub

Use F8 to step through the code line by line, observing what happens in
the worksheet as you go.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc