+ Reply to Thread
Results 1 to 4 of 4

Run macro when a cell are changed

  1. #1
    Registered User
    Join Date
    05-05-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    4

    Run macro when a cell are changed

    I am trying to run a macro when cells are changing in a sheet.
    The macro shall take a cell value from the active sheet and search for this value in a specific column in another sheet.
    The code goes like this:
    Please Login or Register  to view this content.
    This code stops at
    Please Login or Register  to view this content.
    . Why?
    When I run a macro with the same code manuelly it is working fine!

    Hoping for help,
    Christer

  2. #2
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Run macro when a cell are changed

    Hi,

    if you want to manipulate or reference cells on a different sheet from a Worksheet_Change event, you need to qualify the reference properly.

    It's not quite clear what the various "Select" statements refer to. Post a sample file and explain what you want to achieve. In most cases, you don't need to Select in code.

    Something like this, maybe? But I'm only guessing at what you want to do, so please post more context.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-05-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Run macro when a cell are changed

    Hi!
    Thank you for a quick and helpful reply.
    When I first tried your suggestion it stoped on
    Please Login or Register  to view this content.
    When I changed this to
    Please Login or Register  to view this content.
    it worked fine.
    /Christer

  4. #4
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Run macro when a cell are changed

    OK, in this case, you can make the code run faster without using .Select

    Please Login or Register  to view this content.
    Each .Select statement is another step in the procedure and takes its own time to process. Instead of selecting a value and then assigning the selection to a variable, you can assign the value directly to the variable, without stepping through select, as demonstrated above.

    regards,

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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