Solved

New Excel Alert Question

Posted on 2011-02-18
9
244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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
 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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…

615 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