Code required to make my program work please

JoeyBren

New Member
Joined
Sep 17, 2011
Messages
3
Hello,
When I manually insert a "1" into cell A2, the code written in VBA sends an email to me reminding me to "Service lawnmower."
If I try to insert the "1" with a date activated formula, it doesnt work
I have dates set up, one that automatically updates every 20 sec (dynamic) comparing to a rigid (static) date.
When dynamic is higher than static it returns a "1" to cell A2, but nothing happens.
Could you please insert a section of code into my VBA code to make this work, I have tried everything, I am very new to programming.

In worksheet1

Private Sub Worksheet_Change(ByVal Target As Range)
Dim OLook As Object
Dim Mitem As Object
Dim SendAnEmail As Boolean
If Range("A2") <> Range("B2") Then
Set OLook = CreateObject("Outlook.Application")
Set Mitem = OLook.createitem(0)
Mitem.to = "your email goes here"
Mitem.Subject = "Service Alert!"
Mitem.body = "" & Sheet1.Range("F3").Value & " "
Mitem.Send
End If
Set OLook = Nothing
Set Mitem = Nothing
End Sub


To make the the date and time update automatically:

In module 1

Sub Update_Save()
Application.OnTime Now + TimeValue("00:00:20"), "Update_Save"
Application.CalculateFull
ActiveWorkbook.Save

End Sub


Cheers,

Desparate Joeybren
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try this instead

Code:
Private Sub Worksheet_Calculate()
Dim OLook As Object
Dim Mitem As Object
Dim SendAnEmail As Boolean
If Range("A2") <> Range("B2") Then
    Set OLook = CreateObject("Outlook.Application")
    Set Mitem = OLook.createitem(0)
    Mitem.to = "your email goes here"
    Mitem.Subject = "Service Alert!"
    Mitem.body = "" & Sheet1.Range("F3").Value & " "
    Mitem.Send
End If
Set OLook = Nothing
Set Mitem = Nothing
End Sub
 
Upvote 0
Vog,

You are a complete legend.
I have spent hours and hours on this and you had a reply within a minute of me sending the thread. I cant thankyou enough.
eternally greatful

Joeybren
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,470
Members
452,915
Latest member
hannnahheileen

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