This code
This macro just repeats itself and checks col A , col B and col C every 10 seconds
to see if a new value of Date, Time and Message has been entered.
When an entered value in col A and B matches Now, a Msgbox displays
saying so.("Date and TIme value of Now found". Col A is formatted as Date mm/dd/yyyy, col B is formatted as Time(1:30 PM) and C as string.
I can't figure out how to tell Excel to read the correct Time value in col B as
the current time and display the message. Excel reads the correct Date
for Now with this code perfectly every time
Can someone please help with the correct code for telling Excel the value in
col B is the correct time. It's either with the code line for reading the time correctly 'or the formatting or both.
Thanks for anyone's help.
cr
Code:
' Option Explicit
Dim MyRunTimer As Date
col headers A = Date B = Time C = Message
Sub MyMacro()
MyRunTimer = Now + TimeValue("00:00:10")
Dim i As Variant, t As Date, s As String
If Range("D1") <> "" Then
Exit Sub
Else
For i = 2 To [A65536].End(xlUp).Row
If Cells(i, 1).Value = DateValue(Now) Then 'if col A is today's date - works great
If Cells(i, 2).Value = TimeSerial(Now) Then
MsgBox "Both date and time values of current date and time match"
Else
MsgBox "code wrong"
End If
Next
Application.OnTime MyRunTimer, "MyMacro"
End If
End Sub
to see if a new value of Date, Time and Message has been entered.
When an entered value in col A and B matches Now, a Msgbox displays
saying so.("Date and TIme value of Now found". Col A is formatted as Date mm/dd/yyyy, col B is formatted as Time(1:30 PM) and C as string.
I can't figure out how to tell Excel to read the correct Time value in col B as
the current time and display the message. Excel reads the correct Date
for Now with this code perfectly every time
Code:
Cells(i, 1).Value = DateValue(Now)
Can someone please help with the correct code for telling Excel the value in
col B is the correct time. It's either with the code line for reading the time correctly 'or the formatting or both.
Thanks for anyone's help.
cr