Solved

New Excel Alert Question

Posted on 2011-02-18
9
235 Views
Last Modified: 2012-05-11
Experts,

You will see from the sample spreadsheet I have configured conditional alerts in column Q to highlight the cell when values match with those in column D. I would like to add an alert to the condition.

Fernando and Brian have effectively written a formula to accomplish this I would just like to have it applied to spreadsheet.

If you need information on how they accomplished it let me know.

Cheers

One example included the formula, however Fernando's method seemed to work very well.

P.S.

Please be mindful that the values in column D are stock prices and change virtually every second.





Option Explicit

Private Sub Worksheet_Calculate()
Dim xCell As Range
Dim xLastRow As Long
Dim xValue As Variant

xLastRow = ActiveSheet.Range("A1").SpecialCells(xlLastCell).Row

If xLastRow < 2 Then Exit Sub

For Each xCell In Range("O2:O" & xLastRow)
    xValue = xCell.Value
    If Not IsError(xValue) Then
        If xValue <> "" And xValue < 0.0002 Then
            Beep
            Cells(1, 15).Interior.Color = 255
            Exit Sub
        End If
    End If
Next

Cells(1, 15).Interior.Color = 65535

End Sub

Trade-Day-sample.xlsm
0
Comment
Question by:cpatte7372
  • 5
  • 4
9 Comments
 

Author Comment

by:cpatte7372
ID: 34928598
Experts,

For those of you willing help, I need pop out for a bit. I will respond when I get back to me desk

Cheers
0
 
LVL 26

Expert Comment

by:redmondb
ID: 34928908
cpatte7372,

OK, I'm feeling guilty that you're behaving like a gentleman and still have no answer. So strictly on condition that, if this suggestion is acceptable, you don't give me any points, please see attached.

Couple of points...
(1) This still has the original problem of excessive beeping. Worse, the problem is exacerbated as there are now two sets of conditions that will trigger it.
(2) It looks to me that there's a problem in the new conditional format. It assumes that the Column D values have two decimal places, but look at D4 (3.705). So, instead of "=D2", the conditional format should read "=round(D2,2).
(3) Following on from (2), to be on the safe side I've rounded both values in the attached formula.
(4) To slightly speed up the macro, is there any chance you could reduce the no. of rows in the sheet? There are lots of blanks rows below 102 and the values at the bottom of the sheet don't appear to be needed. And could the "#n/a#" rows go or at least be reduced?

Regards,
Brian.

Option Explicit

Private Sub Worksheet_Calculate()
Dim xCell As Range
Dim xLastRow As Long
Dim xValue As Variant
Dim xValue2 As Variant
Dim Point02 As Boolean

xLastRow = ActiveSheet.Range("A1").SpecialCells(xlLastCell).Row

If xLastRow < 2 Then Exit Sub

For Each xCell In Range("O2:O" & xLastRow)
    xValue = xCell.Value
    If Not IsError(xValue) Then
        If xValue <> "" And xValue < 0.0002 Then
            Beep
            Cells(1, 15).Interior.Color = 255
            Point02 = True
            Exit For
        End If
    End If
Next

If Not Point02 Then Cells(1, 15).Interior.Color = 65535

For Each xCell In Range("q2:q" & xLastRow)
    xValue = xCell.Value
    xValue2 = xCell.Offset(0, -13).Value
    If Not IsError(xValue) And Not IsError(xValue2) Then
        If xValue <> "" And xValue2 <> "" And Round(xValue, 2) = Round(xValue2, 2) Then
            Beep
            Cells(1, 17).Interior.Color = 255
            Exit Sub
        End If
    End If
Next

Cells(1, 17).Interior.Color = 65535

End Sub

Open in new window

0
 
LVL 26

Expert Comment

by:redmondb
ID: 34929050
cpatte7372,

A suggestion about the excessive beeping.

There are two extremes - the damn thing beeps all the time or you never get an audio warning. Ideally, you want a beep each time a new occurrence triggers one of the conditions and my concern with this was that the continual checking might interfere with updates from the external application.

What about a button on the sheet which would check whether a condition had been met since the last time you either opened the file or pressed the button? The advantages are...
 - Processing overhead would be incurred only when you hit the button rather than continuously.
 - It avoids the problem of missing a "one-time" beep when you step over to the coffee machine.

[By the way, if anyone is wondering why my previous post required "no points" for me, it's because it was I who suggested that cpatte7372 open this as a new question.]


Regards,
Brian.
0
 

Author Comment

by:cpatte7372
ID: 34938108
Hi Brian,

How's it going mate?

Just got back from a pretty long weekend, and no time to check the any responses to this question.

I have now read and applied your suggestions. As you're aware this cannot be really tested until the markets open. However, I think having a button on the sheet would be absolutely ideal.

Can you show me how add a button to the sheet?

Cheers mate.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
ID: 34942616
cpatte7372,

Hi, I thought that might appeal, so I put something together after my last post.

Please see the comments in Module1.

Cheers,
Brian.

Trade-Day-sample-V2.xlsm
0
 

Author Comment

by:cpatte7372
ID: 35005900
Brian,

You must think how rude I am for not gettng back to you after you've taken time out to help me!
I'm sorry for not getting back to you, I've been incredibly busy lately.

Anyway, when I attempt to open the file I keep on getting the message 'Compile error: variable not defined: xvalue1
0
 
LVL 26

Expert Comment

by:redmondb
ID: 35007253
cpatte7372,

Oops, my mistake. I wrote the code for the "Trading (2)" sheet,  I don't know how that "fossil" code ended up in "Trading". Just delete it from there.

Cheers,
Brian.
0
 

Author Closing Comment

by:cpatte7372
ID: 35306106
Brilliant
0
 
LVL 26

Expert Comment

by:redmondb
ID: 35307499
Thanks, cpatte7372. (Although you weren't supposed to give me any points!)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now