Solved

Excel VBA Rounding Up

Posted on 2011-03-01
4
188 Views
Last Modified: 2012-05-11
Hello Experts,

I have amended some of the code provided by an expert to alert when a certain value is reached in a cell, basically its:

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

I would like a sound when xValue = 0.0002 (0.02%)

Originally it was < 0.0002

However, I think because I'm after an exact number its not alerting. So my guess is I think it needs to be rounded.

I have attached the spreadsheet to illustrate. The cells in question are in column O

I should mention that I have conditionally formatted the column to highlight when the value goes below < 0.0002. But as I mentioned, I would just like a sound alert when the actual value is reached.

The sound has been taken care of by Chris (another expert). I now just need it to be activated when 0.0002 is actually reached.

I hope my explanation isn't to convoluted.

Cheers


Trade-Day--10-Experts-1-.xlsm
0
Comment
Question by:cpatte7372
4 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 35009560
Something like:
 If Application.ROund(val(xValue),4) = 0.0002 Then

Open in new window

0
 

Author Comment

by:cpatte7372
ID: 35011597
rorya

Thanks for responding. I will check it out....
0
 
LVL 24

Expert Comment

by:broomee9
ID: 35356955
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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 in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
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…

828 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