+ Reply to Thread
Results 1 to 7 of 7

VBA that runs when cell within range is changed to specific value

  1. #1
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    VBA that runs when cell within range is changed to specific value

    Hi all,

    I need a VBA that runs if any cell within column A is changed to P. There is a validation on all cells within column A that allows the user to pick from Y, N, or P. The cell is defaulted to a Y value, but I need a macro to run if a P is selected. I have found macros that run on cell change and macros that run if a specific cell returns a value, but I cant tailor any of them to what I need.

    If anyone could help, it would be greatly appreciated.

    Thank you!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA that runs when cell within range is changed to specific value

    Use this as your starting point, this event code is stored in the SHEET module and is self-triggering:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: VBA that runs when cell within range is changed to specific value

    JBeaucaire,

    That works, but creates an additional problem when I try to paste my macro into it. This is what I have.



    Please Login or Register  to view this content.
    The Row does not paste below. Basically, when the user inputs a number into the message box, they corresponding number of rows pastes below the P cell. However, the code highlights the row but never pastes it. Any ideas?
    Last edited by JBeaucaire; 10-24-2014 at 11:02 AM.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA that runs when cell within range is changed to specific value

    Rule #1, no selecting or activating....

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: VBA that runs when cell within range is changed to specific value

    JBeaucaire,

    That works for the first couple of times the cells are changed to P, but stops working and runs this error.
    Capture.PNG

    Run-time error'-214741848(80010108)
    Method of 'Insert' of object 'Range' failed

  6. #6
    Registered User
    Join Date
    09-19-2014
    Location
    Philadelphia,PA
    MS-Off Ver
    2010
    Posts
    54

    Re: VBA that runs when cell within range is changed to specific value

    I think the error occurs whenever the user moves over in the row instead of moving to the next row. Is there anyway to force the user to move down after inserting P? or that makes the error not run?

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA that runs when cell within range is changed to specific value

    User movement isn't impacted in the macro, it merely inserts below the changed "P" rows looking at column A only. I ran that macro with 10 changes in a row in various directions and including changing multiple cells at once. Remotely I can't guess at what is happening to cause that error.

+ 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. highlight a specific cell in a range when changed
    By matt260384 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-17-2014, 11:53 AM
  2. Automatically runs Macro when a cell value is changed
    By gordonf35 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-25-2012, 06:07 PM
  3. Date Stamp column when any cells in specific range are changed
    By Isabell in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-09-2012, 09:20 PM
  4. Macro runs when i click on specific cell
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-19-2009, 05:28 AM
  5. How to define if a specific cell changed?
    By Chipcom in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2007, 03:20 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