+ Reply to Thread
Results 1 to 6 of 6

Condition reached : Make sound and show msgbox with cell value

  1. #1
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    247

    Cool Condition reached : Make sound and show msgbox with cell value

    Hi I have a aheet with products, givings and prices, 1 cell let the price data always updating from the web.

    I put a cell formula that when the online price becomes higher than my price it gives a beep signal.

    Please Login or Register  to view this content.
    PHP Code: 
    Private Declare PtrSafe Function PlaySound Lib "winmm.dll" _
            Alias 
    "PlaySoundA" (ByVal lpszName As String_
            ByVal hModule 
    As LongPtrByVal dwFlags As Long) As Boolean

    Const SND_SYNC = &H0
    Const SND_ASYNC = &H1
    Const SND_FILENAME = &H20000
    Function SoundMe() As String
    'Updateby Extendoffice 20161223
        Call PlaySound("c:\windows\media\Alarm03.wav", _
          0, SND_ASYNC Or SND_FILENAME)
        SoundMe = ""
    End Function 

    The problem is that when it makes a sound I have to search the whole sheet ( a lot) wich one is change from "not" to empty cell.
    It would make me happy if it also open a msgbox that tells me what cell gave the beep

    Thanks to solve this ...

    (ps the checkings happen in colum E and F, but the colum has other values also, so not only the prices ...)

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Condition reached : Make sound and show msgbox with cell value

    Perhaps this will work:


    Add this as the last line in your function - it identifies which cell called the procedure
    Please Login or Register  to view this content.
    Last edited by kev_; 04-15-2017 at 06:18 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    247

    Re: Condition reached : Make sound and show msgbox with cell value

    Hi Ken,

    like this ?
    Please Login or Register  to view this content.
    #value appear if I evaluate , it goes till msgbox and then says #NAME? and end up with #value ...

    sorry if I did wrong ..


    Chris

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Condition reached : Make sound and show msgbox with cell value

    Like this

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    247

    Re: Condition reached : Make sound and show msgbox with cell value

    Hi
    one problem occured, when the msgbox appears, then all macros stop, so no good if I ambusy, away, or asleep ..
    I found the following solution, to let the macro run on ...
    PHP Code: 
        Private Declare Function MessageBox _
            Lib 
    "User32" Alias "MessageBoxA" _
               
    (ByVal hWnd As Long_
                ByVal lpText 
    As String_
                ByVal lpCaption 
    As String_
                ByVal wType 
    As Long_
            
    As Long 
    put it in the same module above the soundme/msg function, and also in the sheet code.

    in the function I putted the line for the messagebox =
    Please Login or Register  to view this content.
    but it doesn't work.. it still stop my macro running ...
    What is wrong please ?

    Thank you
    Chris

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Condition reached : Make sound and show msgbox with cell value

    This is one way to make a message box close after a set time
    Replacing your entire code with the code below and see if it works for you.

    - timed message box added - it should automatically close after 3 seconds
    - you can change the time it takes the message box to close

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 06-01-2015, 06:05 PM
  2. programming to play a sound when cell condition is met
    By pip_taker in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 07-18-2014, 03:12 AM
  3. From Excel run make table query in Access and show msgbox
    By morsoe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2013, 10:32 AM
  4. Show A1 in C3, then A2 in C3, then A3 in C3 until blank cell reached on button press
    By jamiepullen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2008, 06:04 PM
  5. Replies: 1
    Last Post: 08-09-2008, 12:46 AM
  6. Make a MsgBox show the value of a cell in a closed workbook
    By johncassell in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2006, 10:52 AM
  7. [SOLVED] How to make a cell trigger a Sound in Excel
    By justice in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-11-2006, 01:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1