ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autorunning Macros (https://www.excelbanter.com/excel-programming/297822-autorunning-macros.html)

That's Confidential

Autorunning Macros
 
I have the following Macro set up in a workbook:-

Sub datechk()
Application.ScreenUpdating = False
For a = 1 To ActiveSheet.UsedRange.SpecialCells(xlLastCell).Row
If Cells(a, 4).Value < Date Then GoTo hit
Next a
MsgBox ("Accounts appear to be in order")
Application.ScreenUpdating = True
Exit Sub
hit:
MsgBox ("You have some accounts to be deleted!")

Application.ScreenUpdating = True
End Sub


To run this Macro, I have shortcuted it as Ctrl + Q.

Is there any way I can get this Macro to run automatically on opening the
workbook?




pkohler[_3_]

Autorunning Macros
 
Put this code in the module:

Private Sub Auto_Open()

Call datechk

end su

--
Message posted from http://www.ExcelForum.com


Don Guillett[_4_]

Autorunning Macros
 
right click the excel icon to the left of fileview codeleft window
worksheetright window open

--
Don Guillett
SalesAid Software

"That's Confidential" wrote in message
...
I have the following Macro set up in a workbook:-

Sub datechk()
Application.ScreenUpdating = False
For a = 1 To ActiveSheet.UsedRange.SpecialCells(xlLastCell).Row
If Cells(a, 4).Value < Date Then GoTo hit
Next a
MsgBox ("Accounts appear to be in order")
Application.ScreenUpdating = True
Exit Sub
hit:
MsgBox ("You have some accounts to be deleted!")

Application.ScreenUpdating = True
End Sub


To run this Macro, I have shortcuted it as Ctrl + Q.

Is there any way I can get this Macro to run automatically on opening the
workbook?






Toby Erkson[_2_]

Autorunning Macros
 
Huh? I got as far as View Code then got lost.

TC-
Open the VBA editor and click on ThisWorkbook. Paste the below code in the
editor window:
Private Sub Workbook_Open()
Call datechk() ' This is where you put your code to execute when the
workbook Opens
End Sub

Nice and simple :-)
--
Toby Erkson
Oregon, USA

"Don Guillett" wrote in message
...
right click the excel icon to the left of fileview codeleft window
worksheetright window open

--
Don Guillett
SalesAid Software

"That's Confidential" wrote in message
...
I have the following Macro set up in a workbook:-

Sub datechk()
Is there any way I can get this Macro to run automatically on opening the
workbook?




Toby Erkson[_2_]

Autorunning Macros
 
Correction: Right click on ThisWorkbook and select View Code.

"Toby Erkson" wrote in message
Open the VBA editor and click on ThisWorkbook...




Gord Dibben

Autorunning Macros
 
Toby

Don's right-click on the Excel icon and "view code" puts you in the
ThisWorkbook module.

In the left-hand dialog box(general or workbook choices), click "Workbook".
The WorkBook_Open sub/End sub code lines will appear. See right-hand dialog
box for other choices.

Gord Dibben Excel MVP

On Mon, 10 May 2004 11:23:34 -0700, "Toby Erkson"
wrote:

Huh? I got as far as View Code then got lost.

TC-
Open the VBA editor and click on ThisWorkbook. Paste the below code in the
editor window:
Private Sub Workbook_Open()
Call datechk() ' This is where you put your code to execute when the
workbook Opens
End Sub

Nice and simple :-)




All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com