+ Reply to Thread
Results 1 to 6 of 6

run code when a cell is changed

  1. #1
    Registered User
    Join Date
    05-25-2011
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    52

    run code when a cell is changed

    I have a drop down menu for the user to select the week number they want to view. Once they select the week I want code to run that will hide all but the data from that week. I wrote the code and it works when I run it as a macro, but I don't know how to make it automatically run once the week number cell is changed. I don't want to have to tell people to select their choice from the drop down menu, and then run the macro manually. I'm sure there has to be a way to insert this code into the worksheet itself, but I am unsure as to how to write it, and where to put it. Many thanks for the help.

    Here's my macro code if you're interested:

    Please Login or Register  to view this content.
    btw, if it matters, the cell with the drop down menu for week number is cell B1

  2. #2
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: run code when a cell is changed

    Put the following into the relevant worksheet module and change the WS_RANGE referemce to suit

    Please Login or Register  to view this content.
    Dave H

  3. #3
    Registered User
    Join Date
    05-25-2011
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: run code when a cell is changed

    I tried the code, but maybe I don't understand what you mean by change to suit. I am unfamiliar with what WS_RANGE is, so it's hard for me to figure it out. I tried putting in B1 as the range, but it pulled up a box that looked like it wanted me to save something and I could neither save, nor close out, and ended up having to force close excel.

  4. #4
    Registered User
    Join Date
    07-13-2011
    Location
    Chennai, India
    MS-Off Ver
    Excel 2003
    Posts
    7

    Thumbs up Re: run code when a cell is changed

    Hi all,
    I have a
    Last edited by mrsrinivas1988; 07-14-2011 at 09:32 AM.

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: run code when a cell is changed

    Again:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.
    Remember what the dormouse said
    Feed your head

  6. #6
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: run code when a cell is changed

    gryffin13,

    WS_RANGE is specifying the column the change event will trigger on. If your week number is in column A then change "J:J" to "A:A" or if in column L change to "L:L" etc.

    Hope that helps

    Dave H

+ 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