+ Reply to Thread
Results 1 to 12 of 12

Macro autorun on cell change

  1. #1
    Registered User
    Join Date
    06-07-2010
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010
    Posts
    44

    Macro autorun on cell change

    Any ideas why this isn't working?

    Please Login or Register  to view this content.
    Thanks!

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Macro autorun on cell change

    you need to provide more information.

    where is the code?
    assuming event code is actually trigger is the target cell O1 ?
    what are the 2 routines suppose to do? do they run or error?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro autorun on cell change

    Is the code in the correct place?

    What happens with the code when it runs? Add a message box to that code to see if it's running.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    06-07-2010
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Macro autorun on cell change

    I'm not sure if it's in the correct place. It's at the very top of the module with the 2 subs that it calls below it, and a further few functions below them. Is that right?

    The 2 subs it calls, Main and HourlyRate, just manipulate data on the sheet that the cell O1 is on.

    I've put an MsgBox in and it doesn't show when I change the value of Cell O1

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Macro autorun on cell change

    goto the sheet this event code is suppose to work on.
    right click the sheet tab and pick View Code.

    Does that sheet object contain the code?

    If the code is in a standard code module then it will not run.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro autorun on cell change

    To expand on Andy's suggestion

    Worksheet event code is stored on a worksheet module. To add it to your worksheet, do the following:

    Copy the code
    Select the worksheet in which you the code to run
    Right click on the sheet tab and choose View Code, to open the Visual Basic Editor.
    Where the cursor is flashing, choose Edit | Paste

  7. #7
    Registered User
    Join Date
    06-07-2010
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Macro autorun on cell change

    Ok that's running now, I included in the code a MsgBox to see it's firing and it is.

    However! How do I make it run code that is contained in the module?

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro autorun on cell change

    What code in which module? Attach the workbook

  9. #9
    Registered User
    Join Date
    06-07-2010
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Macro autorun on cell change

    Quote Originally Posted by royUK View Post
    What code in which module? Attach the workbook
    The 2 subs that the code in my first post that are called are contained in a separate module, as in the image attached
    Attached Images Attached Images

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Macro autorun on cell change

    That be a picture not a workbook. You sure are making it hard for us to help you

  11. #11
    Registered User
    Join Date
    06-07-2010
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Macro autorun on cell change

    Ok I don't really want to post the entire work book up as it has a lot of info about what I earn + things like bank details.

    I've got it to work now anyways.

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Macro autorun on cell change

    Well you only needed to post a workbook with the code that did not work, no personal data needed.

    Anyway glad you sorted.

+ 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