View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Passing a control to a Sub

Dave,

Thanks, that did it! I didn't realize that there was a different type that
I needed to use. Thanks very much.



"Dave Peterson" wrote:

There are two different labels that you can use in excel. One is the one from
the Forms toolbar and the other is the activex control that you use in userforms
(and on the control toolbox toolbar).

You have to make sure that you use the right one in the called procedu

Option Explicit
Private Sub CommandButton1_Click()
Call SubRoutineNameHere(Me.Label1)
End Sub
Sub SubRoutineNameHere(myLabel As msforms.Label)
MsgBox myLabel.Caption
End Sub




Art wrote:

Hi,

I've got a form with some labels on it. On the click event of one of the
labels, I'd like to pass the label to another sub in the code for that form.
It seems to pass the caption for the label.

I tried, within the click event, to assign the label (me.label1) to a
variable that I declared as a label. This also failed.

Is there a way to make this work?


--

Dave Peterson