Consulting

Results 1 to 4 of 4

Thread: Copy value of active cell to another worksheet

  1. #1
    VBAX Contributor
    Joined
    Jul 2011
    Location
    Manchester
    Posts
    142
    Location

    Copy value of active cell to another worksheet



    Hi


    I have a workbook with worksheets Data & Stats andtrying to copy the value of an active cell to a specific cell in anotherworkbook.


    E.g. If the user clicks in any cell in the range A11-A20only (any other active cell does nothing) on the data sheet that value isautomatically copied over to Cell A2 on the Stats sheet


    I have tried a few options from the net but can’t getanything to work, is anyone able to help please?


    Thanks


    Mykal
    Active Cell,


  2. #2
    VBAX Contributor
    Joined
    Jul 2011
    Location
    Manchester
    Posts
    142
    Location
    Hi again
    I have managed to get the active cell to copy over using
    “Private Sub Worksheet_SelectionChange(ByVal Target AsRange)
    Worksheets("Graphs").Range("A2").Value =ActiveCell.Value
    End Sub”
    Still struggling with limiting the active cells range toJust A11 to A20 if it’s even possible
    Thanks
    Mykal

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Private Sub Worksheet_SelectionChange(ByVal Target AsRange)
    If Intersect (Target, Range("A11:A20")) Is Nothing Then Exit Sub
    Worksheets("Graphs").Range("A2").Value =ActiveCell.Value End Sub”
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    VBAX Contributor
    Joined
    Jul 2011
    Location
    Manchester
    Posts
    142
    Location


    Hi Paul



    Thank you very much, I had just figured it out using this:


    “Private Sub Worksheet_SelectionChange(ByVal Target AsRange)


    If Not Intersect(Range("A11:A20"), Target) IsNothing Then


    'Worksheets("Graphs").Range("A2").Value= ActiveCell.Value


    Else


    End If


    End Sub”





    I came back to mark this as solved and post my code and sawyour response which looks neater, so I have used yours and all works great.


    I really appreciate your time in replying and all the helpyou guys have given me in the past too


    Mykal





Tags for this Thread

Posting Permissions

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