Results 1 to 9 of 9

Worksheet Change, Get previous cell value

This is a discussion on Worksheet Change, Get previous cell value within the Excel Questions forums, part of the Question Forums category; Hi I have a drop down validation cell on an excel sheet and some code on the worksheet change event. ...

  1. #1
    Board Regular
    Join Date
    Mar 2008
    Posts
    160

    Default Worksheet Change, Get previous cell value

    Hi

    I have a drop down validation cell on an excel sheet and some code on the worksheet change event.

    If the user selects from the drop down I want to check the new value and then be able to change it back to the previous value?

    The target is the new value. How do I get the previous value of the cell?

    Thanks

  2. #2
    Board Regular
    Join Date
    Apr 2004
    Posts
    6,715

    Default Re: Worksheet Change, Get previous cell value

    Depends how often this will change, and how many changes you want kept
    Yesterday I felt on top of the world. Today its falling in on me.

  3. #3
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    East Sussex
    Posts
    22,487

    Default Re: Worksheet Change, Get previous cell value

    You can grab the current value, turn events off, use Application.Undo to revert to the previous value, check it, reset the current value if applicable, then turn events back on.

  4. #4
    Board Regular
    Join Date
    Mar 2008
    Posts
    160

    Default Re: Worksheet Change, Get previous cell value

    Thanks For your help guys.

    I think I can get what I want by using the Undo event as suggested by rorya.

    I just check the current value and if its not valid then I just do Application.Undo to get back to the previous value.

    Thanks again!

  5. #5
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    East Sussex
    Posts
    22,487

    Default Re: Worksheet Change, Get previous cell value

    As a matter of interest, why would it not be valid when it's supplied by data validation?

  6. #6
    MrExcel MVP DonkeyOte's Avatar
    Join Date
    Sep 2002
    Location
    Suffolk, UK
    Posts
    9,113

    Default Re: Worksheet Change, Get previous cell value

    well, user could have just hit delete ...
    Does my a$$ look big in this picture ?

  7. #7
    Board Regular
    Join Date
    Mar 2008
    Posts
    160

    Default Re: Worksheet Change, Get previous cell value

    The validity of what the user can select from the drop down is determined by the sum of a column on the spreadsheet.

    So for example if the user selects "Use Sheets" from the dropdown, if the sum of the "Use Qty" column on the spreadsheet is greater than 0, I want to stop the user selecting "Use Sheets", as they are already using "Qty".

    I hope that makes sense.

  8. #8
    New Member
    Join Date
    Jan 2009
    Posts
    1

    Default Re: Worksheet Change, Get previous cell value

    One more question about JC2710's problem.

    For example, we did undo. Then if we want to get the last thing back, what do we need to do? Is there any function which can reverse "undo"?

  9. #9
    MrExcel MVP DonkeyOte's Avatar
    Join Date
    Sep 2002
    Location
    Suffolk, UK
    Posts
    9,113

    Default Re: Worksheet Change, Get previous cell value

    Assuming this is part of the same routine - try repeating the Undo (ie Undo the Undo)
    Does my a$$ look big in this picture ?

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com