VBA Message Box

BankingExcel

New Member
Joined
Feb 10, 2022
Messages
2
Office Version
  1. 2013
HI,

I want a message box to automatically appear conditional on a checklist being completed. I am currently using

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("B3").Value = 0 Then
MsgBox "Checklist Completed- When XXXXX"
End If
End Sub

B3 contains a countif, i.e. when it reaches 0 all items in checklist have been ticked off. This is when I want a message box to appear. Currently I have to go up and click into B3 to get the message and then when I click any other random cell it also pops up. I want the message box to come up once automatically once B3 reaches 0. IS that possible?

Many thanks in advance.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
put it in the worksheet calculate event like this:
VBA Code:
Private Sub Worksheet_Calculate()
If Range("B3").Value = 0 Then
MsgBox "Checklist Completed- When XXXXX"
End If
End Sub
 
Upvote 0
Hi
welcome to forum

Place following in your sheets code page & see if does what you want

VBA Code:
Private Sub Worksheet_Calculate()
    With Me.Range("B3")
        If Val(.ID) <> .Value Then
            .ID = .Value
            If .Value = 0 Then MsgBox "Checklist Completed- When XXXXX", 64, "Completed"
        End If
    End With
End Sub

Msgbox should only appear once when cell value changes to 0

Dave
 
Upvote 0
Hi Dave,

Many thanks for your reply- I have copied your code as suggested but no message box is now appearing. Do you know what the issue might be?

Kind regards,
Maria

Private Sub Worksheet_Calculate()
With Me.Range("B3")
If Val(.ID) <> .Value Then
.ID = .Value
If .Value = 0 Then MsgBox "Checklist Completed- When XXXXX", 64, "Completed"
End If
End With
End Sub
 
Upvote 0
Have placed code in the sheets code page?

Right click tab > View Code

Dave
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

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