Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
md md is offline
external usenet poster
 
Posts: 23
Default running macro when workbook is openned

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default running macro when workbook is openned

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


"MD" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
md md is offline
external usenet poster
 
Posts: 23
Default running macro when workbook is openned

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"

"FSt1" wrote:

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


"MD" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default running macro when workbook is openned

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

"MD" wrote:

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"

"FSt1" wrote:

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


"MD" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
running macro in entire workbook Paul_of_Abingdon[_2_] Excel Discussion (Misc queries) 7 March 28th 08 08:36 PM
Running macro in another workbook Barb Reinhardt Excel Worksheet Functions 1 April 25th 07 08:30 PM
Running Same macro in 250 Worksheets in Same Workbook halem2 Excel Worksheet Functions 3 March 24th 06 08:51 AM
Problems in running a macro in another workbook dhatul Excel Discussion (Misc queries) 3 January 20th 06 08:01 AM
Help:Running a macro in one excel workbook from another workbook R Kapoor Setting up and Configuration of Excel 3 January 13th 06 05:11 AM


All times are GMT +1. The time now is 02:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"