View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Brett Brett is offline
external usenet poster
 
Posts: 113
Default Variable Control name

Hi Jacob, thanks for your response (apologies for delay in returning - had to
sleep!).
I tried Rick's suggestion first and it did the job. Regards, Brett

"Jacob Skaria" wrote:

I am not sure I understood your question...Are you trying to pass the control
name as a variable ....as below

Private Sub CommandButton1_Click()
Dim TBC As Control
Dim strControl As String
strControl = "TextBox1"
Set TBC = UserForm1.Controls(strControl)
MsgBox TBC.Text
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Brett" wrote:

Hi there, I have a sub which gets the value of a Userform (name UF0_QCP)
control name passed into it (tb) but I'm having a little difficulty with the
syntax:

Dim TBC As control
Set TBC = Controls("UF0_QCP." & tb)

What is the missing link please? Regards, Brett