running macro when workbook is openned

M

MD

I have the following macro it should run when the workbook is opened. I keep
getting an error message.
Any ideas. Isthere something that is missing

Option Explicit

Sub Update()
With Sheet5
ActiveSheet.Unprotect
Application.EnableEvents = False

If UserForm4.CheckBox60.Value = True Then
Sheet5.ComboBox3.Visible = True
Sheet5.Label5.Visible = True
Sheet5.TextBox29.Visible = True
Sheet6.ComboBox3.Visible = True
Else
UserForm4.CheckBox60.Value = False
Sheet5.ComboBox3.Visible = False
Sheet5.Label5.Visible = False
Sheet5.TextBox29.Visible = False
Sheet6.ComboBox3.Visible = False
End If
Range("B3").Value = "=TODAY()"
Sheet5.TextBox20.Value = Sheet5.Range("b3").Value
Application.EnableEvents = True
ActiveSheet.Protect
End With
End Sub
 
F

FSt1

hi
what error message are you getting??
is the sub in the workbook module???
also the sub should be titled......
Private Sub Worbook_Open()

regards
FSt1
 
M

MD

Hi FSt1,
I get the following error message:
Run time error '57121' Application-defined or Object-defined error.
with the following highlighted in the workbook code:
Sheets("Sheet5").Activate.

The code on the first posted is in a module named "Update"
 
F

FSt1

hi
sorry to take so long to get back to you. my sister is in the hospital for
an operation. operation done. she's ok now. so.....
i think you are still omitting something. i have read the code you posted (3
times) and cann't find.....Sheets("Sheet5").Activate?????
also. we seem to have a form open that has no code that opened it??????
have we posted the right code that is generating the error?
is the code posted being called by the workbook_open event???

regards
FSt1
 

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