Copying controls in Excel

[b][red]This message was edited by chrish008 at 2002-10-10 7:34:49[/red][/b][hr]
Is it possible to copy a control and all it's associated code within excel such that you create multiple instances of the control, utilising the same code as a template, but having a different identifier so that each instance can work on different parts of the spreadsheet.

I wish to create button controls in excel to add combo boxes sequentially, each working on different data within the spreadsheet (basically completely independent from each other) but using the same foundation code that i have written for a single combo box control.

I have noticed that if you physically copy and paste a control within excel the associated code within the VB development is not also copied. Must this be done with a macro operating within VB? Will this work when the final Excel based app is run?

My code for the single combo box is as follows:

Private Sub ComboBox1_Gotfocus()

a = 0
Dim datacheck As String
datacheck = "initialised"
Do While datacheck <> ""
a = a + 1
datacheck = Worksheets("attenuators").Cells(a, 3)
ComboBox1.AddItem datacheck

End Sub

Private Sub ComboBox1_click()
attselect = ComboBox1.ListIndex + 1
Worksheets("Supply calc").[c8].Value = attselect

End Sub

The cell used to store the value of the variable attselect must be different for each combobox control.

I am very new to VB programming and any help would be greatly appreciated. Gifts of alcohol and lewd reading materials will be available to anyone who can give me some advice.

Cheers! Chris.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!