-
Solved: two routines under one event, but they don't work?
I copied the below code from an example to add multiple routines under a single event: but this one doesn't work (unlike others I made), maybe it's because it's in the workbook object instead of a sheet object?
The error I get is: Compile error: variable not defined.
It points at the word "target"
The code is entered in "this workbook"
[VBA]Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.EnableEvents = False
eventproc10 Target
eventproc11 Target
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Private Sub eventproc10()
End Sub
Run "ShowAll"
End Sub
'part of the hiding worksheets code
Private Sub eventproc11()
Call disable_menu_items
End Sub
'This code is to prevent mailing from the workbook[/VBA]
This one does work for example, it's on a specific worksheet.
[VBA]Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
eventproc4 Target
eventproc5 Target
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Private Sub eventproc4(ByVal Target As Range)
If Not Intersect(Range("g2"), Target) Is Nothing Then
If IsDate(Target) Then
If Target.Value < Date + 1 Then
MsgBox "The date must be tomorrow or later."
Target.ClearContents
End If
End If
End If
End Sub
Private Sub eventproc5(ByVal Target As Range)
If Not Intersect(Range("G2"), Target) Is Nothing Then
'If Target.Value < Date Then
'If Target.Interior.ColorIndex = 3 Then
Target.Interior.ColorIndex = 36
'End If
'End If
End If
End Sub[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules