Create a diary entry from populating a line in a tracker spreadsheet

Draks

New Member
Joined
Sep 27, 2022
Messages
8
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Afternoon all,

Firstly I'm not even sure if this can be done, so I guess that is the first hurdle.
Secondly, If it can can I have some help with even starting the coding/recording a macro as I can't even think how to start this.
what I'm trying to do:
Using the below table when I enter a new line in the tracker send a diary entry to the person Column C (Sarah) for the date in Column M (03/05/23) with the subject: "Quote Follow Up: Column D,E,F. (Testing a Macro choose me)

Date of QuoteQuote RevisionWho's AccountClient NameProject NameProject LocationNumber Of PlotsNet ValueGross ValueMain ProductStandard StockPaintedFollow Up DateStatus of QuoteOutcome Of Follow Up / Action NeededDate Of Next ChaseOrigin of leadAdditional Notes
19/04/2023​
1SarahTestinga macrochoose me
1​
£ 500.00£ 600.00AluminiumYesNo
03/05/2023​
Requires Follow Up

all contacts are internal and have access to the spreadsheet/quotes so don't need to include any links to these.

I currently have a separate tab with Picklists which is where the email addresses are.

I hope that makes sense?

TIA for any help. even if it is just "this can't be done"

Sarah
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Do you have an duplicate employee names ? i.e., two different 'Sarahs' ?

Does everyone have their own, unique email address ?
 
Upvote 0
Do you have an duplicate employee names ? i.e., two different 'Sarahs' ?

Does everyone have their own, unique email address ?
Hi, no all unique names and email addresses.
 
Upvote 0
Hi,

So I have had a bit of a play and updated my spreadsheet as I have been trying to play around with codes. I sort of had it working then I changed something in the code and now it doesn't work at all and I don't know what I broke. Sorry if this isn't making sense. As an aside the emails are unique and populated by a formula as is the follow up date column.

This is my spreadsheet:
Date of QuoteQuote RevisionWho's AccountEmail AddressClient NameProject NameProject LocationNumber Of PlotsNet ValueGross ValueMain Door TypeStandard StockPaintedHanging RailAccessories/LightsFollow Up DateStatus of QuoteOutcome Of Follow Up / Action NeededDate Of Next ChaseOrigin of leadDate of DesignsAdditional Notes
1​
SarahSarah@draks.co.ukThis is to testthe code forcalendar & email
1​
100​
120​
testyesnochrometbc

What I would like to happen is when Date of Quote is populated & Status Of quote is changed to "Requires Follow Up" an email and/or a diary entry is sent to the Account holder (Email Address column) that has the following information
EMAIL:DIARY ENTRY:
Subject:Quote Follow Up ReminderClient, Project, Quote Follow up
Body:Hi Column 3

I have completed the following quote and it is ready for sending:
Client: This is to test
Project: the code for
Location: Calendar & Email
Quote Revision: 1

Please check that you have a reminder for follow up in 14 days on your diary.

Thanks

Sarah
Follow up due:

Client: This is to test
Project: the code for
Location: Calendar & Email
Quote Revision: 1

Please update the Sales Tracker with outcome of Follow up.
Start & End Dates:Start: Date Of Quote
End: Follow Up Date

Code which now doesn't work is:

VBA Code:
Dim xRg As Range

Private Sub Worksheet_Change(ByVal Target As Range)

On Error Resume Next

If Target.Cells.Count > 1 Then Exit Sub

Set xRg = Intersect(Range("P5:P20"), Target)

If xRg Is Nothing Then Exit Sub

If Target.Value > 0 Then

Call Mail_small_Text_Outlook(Target.Row)

End If

End Sub



Sub Mail_small_Text_Outlook(ByVal TargetRow As Long)

Dim xOutApp As Object

Dim xOutMail As Object

Dim xMailBody As String

Dim wsActiveSheet As Worksheet





Set xOutApp = CreateObject("Outlook.Application")

Set xOutMail = xOutApp.CreateItem(0)

Set wsActiveSheet = Application.ActiveSheet



xMailBody = "This quote requires following up, Please check the calendar entry has populated for 14 days' time." & vbNewLine & vbNewLine & _

"Client: " & CStr(wsActiveSheet.Cells(TargetRow, 5).Text) & vbNewLine & _

"Name of Project: " & CStr(wsActiveSheet.Cells(TargetRow, 6).Text) & vbNewLine & vbNewLine & _

"Location: " & CStr(wsActiveSheet.Cells(TargetRow, 7).Text) & vbNewLine & _

"Thank you"



On Error Resume Next

With xOutMail

.To = CStr(wsActiveSheet.Cells(TargetRow, 4).Text)

.CC = ""

.BCC = ""

.Subject = "Quote Follow Up reminder"

.Body = xMailBody

.Display 'or use .Send

End With

On Error GoTo 0

Set xOutMail = Nothing

Set xOutApp = Nothing





Set olOutlook = CreateObject("Outlook.Application")

Set Namespace = olOutlook.GetNamespace("MAPI")

Set oloFolder = Namespace.GetDefaultFolder(9)



LastRow = Cells(Rows.Count, 2).End(xlUp).Row



For I = 5 To LastRow



Description = CStr(wsActiveSheet.Cells(1, 2).Text)

StartDate = Cells(P, 2).Value

EndDate = Cells(P, 3).Value



Set Appointment = Calendar.items.Add



With Appointment

.Start = StartDate

.End = EndDate

.Subject = Description

.Save



End With



Next I

End Sub
 
Upvote 0
VBA Code:
Option Explicit

Sub Send_Email()

    Dim c As Range
    Dim strBody As String
    Dim OutLookApp As Object
    Dim OutLookMailItem As Object
    Dim i As Integer
    On Error Resume Next
    
    
    For Each c In Range("D2:D1000")
    strBody = "Hi " & c.Offset(0, -1).Value & " I have completed the following quote and it is ready for sending:" & "<br></br><br></br>" _
                & "CLIENT : " & c.Offset(0, 1).Value & "<br></br><br></br>" _
                & "PROJECT : " & c.Offset(0, 2).Value & "<br></br><br></br>" _
                & "LOCATION : " & c.Offset(0, 3).Value & "<br></br><br></br><br></br>" _
                & "Please check that you have a reminder for follow up in 14 days on your diary." & "<br></br><br></br>" _
                & "Thanks" & "<br></br>" _
                & "Sarah"
                
        If c.Value <> "" Then
            Set OutLookApp = CreateObject("Outlook.application")
            Set OutLookMailItem = OutLookApp.CreateItem(0)
            With OutLookMailItem
                    .To = c.Value
                    .CC = ""
                    .Subject = "Quote Follow Up Reminder"
                    .HTMLBody = strBody
                    '.Attachments.Add
                    .Display
                    '.Send
            End With
        End If
    Next c

End Sub
 
Upvote 0
Solution
VBA Code:
Option Explicit

Sub Send_Email()

    Dim c As Range
    Dim strBody As String
    Dim OutLookApp As Object
    Dim OutLookMailItem As Object
    Dim i As Integer
    On Error Resume Next
   
   
    For Each c In Range("D2:D1000")
    strBody = "Hi " & c.Offset(0, -1).Value & " I have completed the following quote and it is ready for sending:" & "<br></br><br></br>" _
                & "CLIENT : " & c.Offset(0, 1).Value & "<br></br><br></br>" _
                & "PROJECT : " & c.Offset(0, 2).Value & "<br></br><br></br>" _
                & "LOCATION : " & c.Offset(0, 3).Value & "<br></br><br></br><br></br>" _
                & "Please check that you have a reminder for follow up in 14 days on your diary." & "<br></br><br></br>" _
                & "Thanks" & "<br></br>" _
                & "Sarah"
               
        If c.Value <> "" Then
            Set OutLookApp = CreateObject("Outlook.application")
            Set OutLookMailItem = OutLookApp.CreateItem(0)
            With OutLookMailItem
                    .To = c.Value
                    .CC = ""
                    .Subject = "Quote Follow Up Reminder"
                    .HTMLBody = strBody
                    '.Attachments.Add
                    .Display
                    '.Send
            End With
        End If
    Next c

End Sub
Thank you so much Logit, that works beautifully to create the email.
I am possibly pushing my luck here but wondered if you can help as if I put in my "Worksheet change" code it is throwing an error. and I am going code blind trying to read the help pages and work out where I have gone wrong. (this is my first step back into code in about 5 years and I wasn't great at it then, hence my ignorance/stupidity)
If I put in as I did earlier (see below) then it throws: Compile Error: Sub or Function not defined and
If I change the `call line` to: "Call Send_Email(Target.Row)" Then I get: Compile Error: Wrong number of arguments or Invalid property assignment.

Code Typed:
Dim xRg As Range

Private Sub Worksheet_Change(ByVal Target As Range)

On Error Resume Next

If Target.Cells.Count > 1 Then Exit Sub

Set xRg = Intersect(Range("P5:P20"), Target)

If xRg Is Nothing Then Exit Sub

If Target.Value > 0 Then

Call Mail_small_Text_Outlook(Target.Row)

End If

End Sub

Any Help would be much appreciated even if it is just; this can only be run manually. Thank you
 
Upvote 0
The following works here. Note that my macro calls "Send_Email" as the name of the emailing macro.

VBA Code:
Option Explicit

Dim xRg As Range

Private Sub Worksheet_Change(ByVal Target As Range)

On Error Resume Next

    If Target.Cells.Count > 1 Then Exit Sub
    
        Set xRg = Intersect(Range("P5:P20"), Target)
        
            If xRg Is Nothing Then Exit Sub
        
            If Target.Value > 0 Then
        
                Send_Email
    
            End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top