Consulting

Results 1 to 4 of 4

Thread: Grabbing the cell value before it is changed (or on cell selection)

  1. #1
    VBAX Regular
    Joined
    Dec 2007
    Posts
    78
    Location

    Grabbing the cell value before it is changed (or on cell selection)

    Dear all,

    Am using "ByVal Target As Range" to identify cells that have changed, but how do I assign the value in that cell to a variable AFTER the cell has been selected but BEFORE the value has been changed (without assigning variables to and array dim'd by 255 columns and 65536 rows #-)?

    I think in hindsight the problem was in my coding.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Using the SelectionChange event to catch the target value.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Dec 2007
    Posts
    78
    Location
    Cheers, that works nicely except (unless I'm imagining it), e.g....

    A1 contains 100 - A2 contains 200 - I select A1, 100 is assigned to a var within the selection change event.

    A1 is now the activecell.

    I change A1 from 100 to 150 and press return =>

    A1 contains 150 - A2 contains 200 - A2 is now the activecell, 200 is assigned to the var within the selectionchange event.

    I press undo/ CTRL-Z/ etc...

    A1 contains 100 - A2 contains 200 - A2 is now the activecell, 200 remains assigned to the var within the selectionchange event (i.e. I hoped that 150 would have been assigned).

    I'll keep on persevering but does that ring a bell? If yes, can I screen it out?

    I think in hindsight the problem was in my coding.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Oh no, the undo stack is trashed when you run code.

    Also, as soon as you select A2 you catch the 200 value as you note, why would you want undo to assign 150, a value it never had , to it?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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