- Joined
- Dec 13, 2017
- Messages
- 71
- Reaction score
- 19
I have a worksheet that that a user can enter "Pending" in column M. That is a temporary entry, eventually it is deleted.
The code below does work on the initial entry. But similar code does not work on Private Sub Worksheet_BeforeDelete().
Private Sub Worksheet_Change(ByVal Target As Range)
' Promts user wnen Pending is selected.
Application.Cursor = xlDefault
If Not Application.Intersect(Target(1), Me.Columns("M")) Is Nothing Then
Application.Speech.Speak "Schedule two. appointments on your calendar. The first appointment. is a reminder. to send a contact letter. (if no response from the Phone call). Use the Red date to the right. The second appointment. is a reminder. two weeks later. to cancel the consult. if NO response from earlier attempts.", SpeakAsync:=True
VBA.MsgBox "Schedule two appointments on your calendar. The first appointment is a reminder to send a contact letter (if no response from Phone call.) Use the Red date to the right. The second appointment is a reminder two weeks later to cancel the consult, if NO response from earlier attempts.", vbOKOnly + vbInformation, _
"Vocational Services Reminder"
'Opens Outlook appointment Calendar.
Dim olApp As Object ' Outlook.Application
Set olApp = CreateObject("Outlook.Application")
olApp.Session.GetDefaultFolder(olFolderCalendar).Display
End If
End Sub
I am attempting to run code below prior to the deletion of the entry.
Here is the problem code:
Private Sub Worksheet_BeforeDelete()
' Promts user wnen Pending is selected.
Application.Cursor = xlDefault
If Not Application.Intersect(Target(1), Me.Columns("M")) Is Nothing Then
Application.Speech.Speak "Delete the 2 appointments on your calendar. The first appointment was the date to the right of Pending. The second was 2 weeks later", SpeakAsync:=True
MsgBox " Delete the 2 appointments on your calendar. The first appointment was the date to the right of Pending. The second was 2 weeks later. ", vbOKOnly + vbInformation, "Vocational Services Reminder"
'Opens Outlook appointment Calendar.
Dim olApp As Object ' Outlook.Application
Set olApp = CreateObject("Outlook.Application")
olApp.Session.GetDefaultFolder(olFolderCalendar).Display
End Sub
When I debug, I get a "Sub or Function not defined" error on "Target". Yes the 2 codes are similar. I changed the messages only.
It is probably something very simple .
The code below does work on the initial entry. But similar code does not work on Private Sub Worksheet_BeforeDelete().
Private Sub Worksheet_Change(ByVal Target As Range)
' Promts user wnen Pending is selected.
Application.Cursor = xlDefault
If Not Application.Intersect(Target(1), Me.Columns("M")) Is Nothing Then
Application.Speech.Speak "Schedule two. appointments on your calendar. The first appointment. is a reminder. to send a contact letter. (if no response from the Phone call). Use the Red date to the right. The second appointment. is a reminder. two weeks later. to cancel the consult. if NO response from earlier attempts.", SpeakAsync:=True
VBA.MsgBox "Schedule two appointments on your calendar. The first appointment is a reminder to send a contact letter (if no response from Phone call.) Use the Red date to the right. The second appointment is a reminder two weeks later to cancel the consult, if NO response from earlier attempts.", vbOKOnly + vbInformation, _
"Vocational Services Reminder"
'Opens Outlook appointment Calendar.
Dim olApp As Object ' Outlook.Application
Set olApp = CreateObject("Outlook.Application")
olApp.Session.GetDefaultFolder(olFolderCalendar).Display
End If
End Sub
I am attempting to run code below prior to the deletion of the entry.
Here is the problem code:
Private Sub Worksheet_BeforeDelete()
' Promts user wnen Pending is selected.
Application.Cursor = xlDefault
If Not Application.Intersect(Target(1), Me.Columns("M")) Is Nothing Then
Application.Speech.Speak "Delete the 2 appointments on your calendar. The first appointment was the date to the right of Pending. The second was 2 weeks later", SpeakAsync:=True
MsgBox " Delete the 2 appointments on your calendar. The first appointment was the date to the right of Pending. The second was 2 weeks later. ", vbOKOnly + vbInformation, "Vocational Services Reminder"
'Opens Outlook appointment Calendar.
Dim olApp As Object ' Outlook.Application
Set olApp = CreateObject("Outlook.Application")
olApp.Session.GetDefaultFolder(olFolderCalendar).Display
End Sub
When I debug, I get a "Sub or Function not defined" error on "Target". Yes the 2 codes are similar. I changed the messages only.
It is probably something very simple .