+ Reply to Thread
Results 1 to 13 of 13

Looping through cells

  1. #1
    Registered User
    Join Date
    03-25-2013
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    7

    Looping through cells

    1. Hi, I'm trying to add a .wav sound to all cells in a column if it equals "! ALERT !". I have created a macro and added the following code:

    Please Login or Register  to view this content.
    This works for the first cell in the column and I'm assuming I'll to add a loop within it to apply the same to the rest of the column cells. I would also like to reference .wav files in other files but using c:\BERT\BEAM-ME-UP-SCOTTY doesn't work? How do I do this and is it something to do with the FILEPATH?

    This is my first macro and I would appreciate help in achieving this, please help.

    Many thanks

    J

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Looping through cells

    Change your code to this and you won't need to loop.

    Please Login or Register  to view this content.
    To answer your second question - Nope you can play any wav you like - I've even got some AC/DC if you want it..

    ARTE ET MARTE
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    03-25-2013
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Looping through cells

    Thanks, I'm getting a runtime error 438
    Object doesn't this property or method

    Any ideas??

    Thanks

    J

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Looping through cells

    Hit the debug when it errors and check which line in the code it takes you to... Highlighted in yellow.

  5. #5
    Registered User
    Join Date
    03-25-2013
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Looping through cells

    Hi highlighted in yellow ( in italics) below...

    If Target.comlumn <> 52 Then Exit Sub
    If Target.Row < 4 Then Exit Sub
    Threshold = "! ALERT !"
    If Target.Value = Threshold Then PlayWAV

    Thanks

    J

  6. #6
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Looping through cells

    My fault - spelling mistake

    should read............ If Target.column <> 52 Then Exit Sub

    so now the code will only run when you click in column AZ rows 4 and above
    Last edited by AndyLitch; 04-07-2013 at 10:35 AM.

  7. #7
    Registered User
    Join Date
    03-25-2013
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Looping through cells

    Hi again. No error or sound now??

    Thanks

    J

  8. #8
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Looping through cells

    Hi
    Would it be possible for you to upload a copy of the file so we can get a clearer understanding?.. It will speed up the process and is more likely to achieve the best possible solution.
    Just be mindful of the fact that you're not supposed to upload sensitive or secret information

    1. Select Edit Message or Reply
    2. Select "Go Advanced" at the bottom right of the message area
    3. Select the paper clip on the menu bar
    4. Follow the wizard instructions for uploading a file.

  9. #9
    Registered User
    Join Date
    03-25-2013
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Looping through cells

    Grrr, the upload window is not loading.

    Is there anything else I can try to get it working?

    Many thanks

    J

  10. #10
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Looping through cells

    To be perfectly honest - I don't think sound is your best option..
    How about highlighting non compliant cells in red automatically ?

    How about something like this .

    Error Detect.xlsm
    Last edited by AndyLitch; 04-07-2013 at 11:17 AM.

  11. #11
    Registered User
    Join Date
    03-25-2013
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Looping through cells

    Book1.xlsx

    Attached now, I think1

  12. #12
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Looping through cells

    I'll never get that to work in a million years........ It's a picture

  13. #13
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Looping through cells

    OK put this code in the sheet3 code module

    Please Login or Register  to view this content.
    Last edited by AndyLitch; 04-07-2013 at 12:01 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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