VBA example not working

  • Thread starter Thread starter papa
  • Start date Start date
P

papa

I have been reading about VBA so I can do some code stuff
in Excel. I have followed the following example out of a
book on 2 different computers - but it does not work.

What I have is:
Private Sub CmdClickMe_Click()
frmCH01.Caption = "I have a new caption!"
MsgBox "The caption has been changed."
End Sub


What I get is:
Run-time error 424
Object required.

I don't understand what the problem is.

TIA
papa
 
Private Sub CmdClickMe_Click()
frmCh10.Caption = "I have a new caption!"
MsgBox "The caption has been changed."
End Sub

worked for me on a form name frmCh10 with a commandbutton CmdClickMe and
the code in the userform module

try

me.Caption = "I have a new caption!"

if you continue to have trouble.
 
Hi

Did you first create a userform and then name it frmCH01 ?
Open the vbe and create a new userform and name it frmCH01 in the properties
dialog.
Change the code to this and re-run.

frmch01.Caption = "I have a new caption!"

MsgBox "The caption has been changed."

frmch01.Show

And you should see the form with your caption.


HTH

Ken
 
Have you put that code in the form module, not a standard code module?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
that helped thanks.
The book told me to name the command button something else
and then gave example code with the wrong name.
 

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

Back
Top