VBA code which show a Pop Box in Excel if condition is meet.

Lucky Cool

New Member
Joined
Oct 22, 2019
Messages
3
Hello Friends

I am in little trouble hope you will help me.

I have a excel sheet and into this sheet data is fetch from another Software (Live Data).

[TABLE="width: 614"]
<colgroup><col><col span="2"><col></colgroup><tbody>[TR]
[TD]Company Name[/TD]
[TD]Value[/TD]
[TD]Reaching Value[/TD]
[TD]Status[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]1000[/TD]
[TD]2500[/TD]
[TD]Sell[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]5000[/TD]
[TD]2500[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]4000[/TD]
[TD]2500[/TD]
[TD]Buy[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]4526[/TD]
[TD]2500[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]E[/TD]
[TD]1879[/TD]
[TD]2500[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]F[/TD]
[TD]4000[/TD]
[TD]2500[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]G[/TD]
[TD]4000[/TD]
[TD]2500[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I Put Formula in Status Column Now I want If Column is blank so its ok But if Status Column Find Sell or Buy then it Pop up a Message Box "Please Review It" with Cell Name like D2 or D4 or if there is 5 sell or Buy then 5 popup box will Open automatically.

&

If i Closed the sheet and open sheet again and if again is there any sell or buy then show pop up again automatically....
I do not want any macro button because for this i have to always click button.

Hope you can understand my Query

Please help. Thanks in Advance.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Re: Need a [VBA] code which show a Pop Box in Excel if condition is meet.

Try this:
Put the code in the code module of the sheet in question:

Code:
[FONT=Lucida Console][COLOR=Royalblue]Private[/COLOR] [COLOR=Royalblue]Sub[/COLOR] Worksheet_Activate()
[COLOR=Royalblue]Dim[/COLOR] i [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR]
[COLOR=Royalblue]Dim[/COLOR] va

va = Range([COLOR=Darkcyan]"D1"[/COLOR], Cells(Rows.Count, [COLOR=Darkcyan]"D"[/COLOR]).[COLOR=Royalblue]End[/COLOR](xlUp))

[COLOR=Royalblue]For[/COLOR] i = [COLOR=Brown]2[/COLOR] [COLOR=Royalblue]To[/COLOR] [COLOR=Royalblue]UBound[/COLOR](va, [COLOR=Brown]1[/COLOR])
    [COLOR=Royalblue]If[/COLOR] va(i, [COLOR=Brown]1[/COLOR]) = [COLOR=Darkcyan]"Buy"[/COLOR] [COLOR=Royalblue]Or[/COLOR] va(i, [COLOR=Brown]1[/COLOR]) = [COLOR=Darkcyan]"Sell"[/COLOR] [COLOR=Royalblue]Then[/COLOR] MsgBox [COLOR=Darkcyan]"Review this: D"[/COLOR] & i
[COLOR=Royalblue]Next[/COLOR]

[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]Sub[/COLOR][/FONT]
 
Upvote 0
Re: Need a [VBA] code which show a Pop Box in Excel if condition is meet.

Hi,

Live data might require you to test another event Worksheet_Calculate() ...

Hope this will help
 
Upvote 0
Re: Need a [VBA] code which show a Pop Box in Excel if condition is meet.

Can you explain in more detail "it is not Working"?
Private Sub Worksheet_Activate() is triggered when you open another sheet then go back to the sheet.
 
Upvote 0
Re: Need a [VBA] code which show a Pop Box in Excel if condition is meet.

Thank You so much James & Akuini. Now its Working, I have Changed
Worksheet_Activate() into Worksheet_Calculate(). :)

Again Thank You So Much..
 
Upvote 0
Re: Need a [VBA] code which show a Pop Box in Excel if condition is meet.

You are welcome :smile:
 
Upvote 0
Re: Need a [VBA] code which show a Pop Box in Excel if condition is meet.

You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
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