Last part of VBA code/Msg box not coming up when workbook opened, only when specified range is refreshed

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
888
Office Version
  1. 365
Platform
  1. Windows
The below code works with the exception of the line:

If Range("Z1").Value = "1" Then
MsgBox ("AUDIT LIST UPDATE REQUIRED")

I want the code to check cell Z1 (which is a formula) when the workbook is opened and display the message box if the value is 1, however the msg box only comes up if I refresh cell Z1.

Any suggestions?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Target, Range("D:D")) Is Nothing Then
        If Target <> "" Then Call Notify
End If

If Range("Z1").Value = "1" Then
    MsgBox ("AUDIT LIST UPDATE REQUIRED")

End If
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You need to place the macro in the code module for ThisWorkbook not in the worksheet code module. Change the sheet name (in red) to suit your needs.
Rich (BB code):
Private Sub Workbook_Open()
    If Sheets("Sheet1").Range("Z1").Value = "1" Then
    MsgBox ("AUDIT LIST UPDATE REQUIRED")
End Sub
 
Upvote 0
Solution
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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