Solved

New Excel Alert Question

Posted on 2011-02-18
9
238 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Remove duplicates using cell values VBA 2 32
Excel error  #DIV/0! 7 18
Change date stored as "short text" YYYYMMDD to MM/DD/YYYY? 27 28
If help 9 48
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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