how to set a userform's button caption equal to a variable in the main procedure?

A

akh2103

Hello--does anyone know how to set the caption on a command button of a
userform equal to a variable generated in a main procedure (in which
the userform procedure is loaded and displayed). Thanks, Abe
 
N

Norman Jones

Hi Akh,

In a standard module, before any code, paste the fillowing code:

'=============>>
Option Explicit
Public strCaption As String

'--------------->>

Public Sub Tester()
strCaption = "Your Caption"
UserForm1.Show
End Sub
'<<=============

In the useform module, try:
'=============>>
Private Sub UserForm_Initialize()
Me.CommandButton1.Caption = strCaption
End Sub
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top