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

Lucky Cool

New Member
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).

Company NameValueReaching ValueStatus
A10002500Sell
B50002500
C40002500Buy
D45262500
E18792500
F40002500
G40002500

<colgroup><col><col span="2"><col></colgroup><tbody>
</tbody>

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.
 

Akuini

Well-known Member
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]
 

James006

Well-known Member
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
 

Akuini

Well-known Member
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.
 

Lucky Cool

New Member
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..
 

James006

Well-known Member
Re: Need a [VBA] code which show a Pop Box in Excel if condition is meet.

You are welcome :)
 

Akuini

Well-known Member
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.:)
 

Some videos you may like

This Week's Hot Topics

  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • find many based on a certain criteria
    good evening, I hope someone can help me? I have a workbook sheet 2 contains lots of data.... I would like to be able to find anything on sheet...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
  • Text Format
    I have a sheet for user to keyin the data. The format of the data can be 451 / 1903, 0012 / 9908 or 00287 / 0099. The number after the "/" is...
  • Syntax errors
    Good Morning, Trying to compile a workbook, I keep getting a few errors. Here are the first two: [code=rich]Syntax Error: Function...
Top