Message Box VBA

Superbum138

New Member
Joined
Dec 1, 2017
Messages
2
I am trying to get a message box to fire automatically based on a cell value. Here is the setup:

I have a "configurator" tab (Sheet 2) that has an ActiveX drop down box with a list of names that corresponds to a table of names/job titles on a logic tab (Sheet 3). When you select your name on the ActiveX control the, cell link changes the value based on the name selected i.e. if the third name is selected the control will put 3 in the linked cell. This value is then used by a Vlookup to add the person's name and title to a output letter. There is no issue with this function.

What I would like to do is make the sheet fire a message box when a specific user is selected from the drop down box. If Jon Doe was the 17th on the list then I want a message box to fire that says Hello Jon Doe!

What I did was link a cell on the configurator sheet to the ActiveX cell link value on the logic sheet so whatever number was displayed on the logic sheet would also be displayed on the configurator sheet so that my VBA code could run within that sheet and not have to call other sheets.

The issue resides that the cell I am trying to use to fire the message box contains the formula =Logic!D1627 so being a formula driven value I cannot simply use Worksheet_Change(ByVal Target As Range) as this requires a manual change to trigger.

I have the code:

Private Sub Worksheet_Calculate()
If [G14] = 17 Then
MsgBox "Hello Jon Doe!"
End If
End Sub


Which works but it fires every time you click anywhere in the sheet now. How can I have this message box fire only once unless that value in G14 changes again?

I have tried:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range
Set A = Range("G14")
If Intersect(Target, A) Is Nothing Then Exit Sub
If Target.Value = 17 Then
MsgBox "Hello Jon Doe!"
End If
End Sub

But this requires a manual change not a formula driven value.

I am stumped.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
instead of INTERSECT, wouldnt you just check for that 1 cell to change:

if Target .address = "$G$14" then msgbox "Hello Jon Doe"


 
Upvote 0
Maybe I am having a slow day but is this what you are talking about?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range
Set A = Range("G14")
If Target.Address = "$G$14" Then
If Target.Value = 17 Then
MsgBox "Hello Jon Doe!"
End If
End Sub

That didn't seem to work. Keep in mind that that the value in G14 is formula driven coming from my logic sheet so I was under the impression a Worksheet_change wouldn't work as that has to be a manual change.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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