VBA pop up message

Chaozfate

Board Regular
Joined
Mar 15, 2017
Messages
71
Dear All,

I have the following VBA running for my excel. The purpose is to serve as a date reminder if my formulated column J on my sheet 3 change to a date.

If works just fine if I last save my excel on sheet 3, the pop up message is working as intended, but however, if i last save my excel on sheet 1, the pop up message won't appear.

Would be appreciated if anyone can help me revised my VBA code following to instruct excel to show the pop up based on the criteria on sheet 3, regardless of my last save is at any sheet.


Private Sub Workbook_open()
Dim r As Long
For r = 2 To 99999
If Range("J" & r).Value = Date Then
MsgBox "There are Products mature today/declaring dividends, please check and post"

Exit Sub
End If
Next r

End Sub


Thanks and regards
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try (note the "." in front of "Range")
VBA Code:
Private Sub Workbook_open()
    Dim r As Long
    With ThisWorkbook.Worksheets("Sheet3")
        For r = 2 To 99999
            If .Range("J" & r).Value = Date Then
                MsgBox "There are Products mature today/declaring dividends, please check and post"
                Exit Sub
            End If
        Next r
    End With
End Sub
 
Upvote 0
Wow, it works! would you mind to explain whats with the "." infront of the "range"? haha.

i tried with and without, the "." trigger the pop up message eventhough i last save on other sheet, without the ".", it wont trigger, why is it?
 
Upvote 0
The "with/end with" statement says that objects that start with a "." refer to what follows the "with" - in this case, Sheet3. So that range isn't just the range in whatever sheet happens to be active, it is always that range in Sheet3.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,668
Members
448,977
Latest member
moonlight6

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