Consulting

Results 1 to 2 of 2

Thread: Getting VBA to decide which cell to use

  1. #1
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location

    Getting VBA to decide which cell to use

    So I thought I was doing ok...

    I have a trigger in the "Worksheet_Change(ByVal Target As Range)" code so that when someone picks a number from a validation list, a macro is run which uses the value of the active cell (which is of course the cell where the dropdown was just used) in a vlookup, and returns the results in another cell of the same column.

    The problem now is that if the user decides to enter the text manually, he's going to hit the Enter key, which triggers the code... but now the active cell has shifted down one.

    So what are my options please?

    I know I could change the code so that it uses the value of the cell one above the (now) active cell, but then that would fail if the user uses the dropdown choices
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    use Target instead; that's the cell(s) which has just been changed.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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