Naming objects on creation
"Andy" wrote in message
...
In VBA I can create worksheets and command-buttons but I
want to give them specific 'object names' to make
subsequent programming easier. I realise I cannot do this
programmatically at run time so am looing for a way to do
it on creation, any help would be great,
Ta
Andy
Andy,
Is this something like what you had in mind?
Option Explicit
Sub Main()
Dim wks As Worksheet
Set wks = Worksheets.Add
Dim cmd As CommandButton
Set cmd = UserForm1.CommandButton1
Call MsgBox(wks.Name & vbNewLine & cmd.Caption)
End Sub
--
Bob Kilmer
|