Consulting

Results 1 to 3 of 3

Thread: Select Previously Edited Cell

  1. #1
    VBAX Regular
    Joined
    May 2008
    Posts
    46
    Location

    Select Previously Edited Cell

    I need to create a macro that will be able to move data from a previously entered cell to a different sheet. I'm running into a problem with the first part of it.

    If I enter data into cell B5 and either press enter, click into another cell, press tab or any other way of moving cells I need the macro to somehow record B5 and then I can reference that in another macro to copy and paste it elsewhere. I assume this code will have to go into the Private Sub using "Worksheet_SelectionChange" and then I can use another macro to execute a copy and paste when I want it to. I just don't know if it's possible to reference a previosly entered cell.

    The other challenge I have is that I want the copy and paste to only trigger on certain cells. Meaning if I enter data in any cell in B5:Z5 then I want to take that data and enter it into another sheet.
    ________________________________________
    The more questions I ask and the more I learn, I realize that I don't know squat!!!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    First part, save the value in a module scope variable, and use that later.

    To just work in B5:Z5, test that range a like so

    [vba]

    If Not Intersect (Target, Me.Range("B5:Z5")) Is Nothing Then

    'do stuff
    End If
    [/vba]
    ____________________________________________
    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
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    I'd look at the Worksheet_Change event rather than SelectionChange.

Posting Permissions

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