Macro Not Firing

A-Train

New Member
Joined
Apr 6, 2011
Messages
8
Hi

I want a message box to popup when cell J5 is >= cell J6 and I am using the following:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$J$5" Then Exit Sub
If [J5].Value >= [J6].Value Then MsgBox "Limit Reached"
End Sub

The above code is working when J5 is manually updated, however J5 is referencing another cell and when the other cell is updated the macro is not firing and the message box is not popping up.

Thanks

A-Train
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
That's because this line is saying, if you're not in cell J5 then exit the sub
Code:
If Target.Address <> "$J$5" Then Exit Sub
Try
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If [J5].Value >= [J6].Value Then MsgBox "Limit Reached"
End Sub
 
Upvote 0
I am still having a problem with this code.

The message box will pop up while I am in the speadsheet fine. However I need it to run in the background. The spreadsheet is constantly being updated with a live web feed and this is what I need to kick off the macro.

Any ideas why this code isn't doing the trick?

Thanks
A-Train
 
Upvote 0
Maybe change the sub to:
Code:
Private Sub Worksheet_Calculate()
If [J5].Value >= [J6].Value Then MsgBox "Limit Reached"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,911
Members
452,949
Latest member
beartooth91

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