Need macro to automatically update

A-Train

New Member
Joined
Apr 6, 2011
Messages
8
Hi,

I need a mesage box to appear once cell A1 is over the value 50,000. I need the sheet to be in the background so I want the macro to be either contantly running or updating every few minutes.

I am able to get the popup box to work but not the time function. This is what I have so far.

Sub Macro5second()
If [A1].Value >= 50000 Then MsgBox "Time to trade boss!"
Application.OnTime Now() + TimeValue("00:05:00"), "Macro5second"
End Sub

Thanks
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Can't you just put your line of code into the worksheet_change event, so that it fires each time A1 changes? :
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If [A1].Value >= 50000 Then MsgBox "Time to trade boss!"
End Sub
 
Upvote 0
Pleasure! Saves messing around with having a counter running etc, which can get messy.
 
Upvote 0
One issue with this script, the macro seems to run when any cell is updated not just A1. Any ideas?
 
Upvote 0
Yes - it's the worksheet_change event so it will run every time something changes on the sheet.
If you only want it to respond to changes in A1, then do a test for A1 first:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
If [A1].Value >= 50000 Then MsgBox "Time to trade boss!"
End Sub
 
Upvote 0
By the way, I'm forgetting my manners! I'm afraid I didn't notice that you were new to Mr Excel, so welcome to the board!!
 
Upvote 0
Thanks man, appreciate it.

Ok, I'm getting close here.

The message box will appear when I manually update cell A1. However A1 is referencing other cells and the box isn't popping up when they update cell A1 via F9 or auto calculate.

Do you know how I can solve this?

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,472
Members
452,915
Latest member
hannnahheileen

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