Howdy, Stranger!

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

Categories

Copying controls in Excel

chrish008chrish008 Member Posts: 17
[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()

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

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.



Comments

  • Andre YoungAndre Young USAMember Posts: 0

    _____ \ http://forcoder.org \ free video tutorials and ebooks about // Perl JavaScript Go Objective-C Assembly PL/SQL Swift Visual Basic .NET Ruby Visual Basic Java C++ Scratch C MATLAB Delphi C# R Python PHP ML Logo Scala Rust Scheme FoxPro Prolog COBOL Dart VBScript Lua Erlang Bash Transact-SQL Lisp Fortran Apex Ada Crystal F# Julia LabVIEW Kotlin ABAP Hack Alice Clojure SAS Awk D // __

Sign In or Register to comment.