+ Reply to Thread
Results 1 to 4 of 4

On click within a range, copy and paste cell

  1. #1
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    807

    On click within a range, copy and paste cell

    I've been battling to get what should be a simple bit of VBA to run: when clicking in a range, that cell within the range is copied and pasted to another location within the same sheet.

    Grateful for any help

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: On click within a range, copy and paste cell

    Are you looking to use the SelectionChange event ?

    Perhaps you could post what you have in mind... specifics etc...

    Below is a very generic approach - would copy intersect of selected range and A1:C10 and paste resulting cells to the first blank row in Column Z (and below / right as appropriate pending size of Intersecting range)

    Please Login or Register  to view this content.
    To insert the above right click on Tab of interest and select View Code pasting above into resulting window.

    Using the selectionchange event is not necessarily a good thing... you might want to make the action more deliberate (eg DoubleClick)

  3. #3
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    807

    Re: On click within a range, copy and paste cell

    Thanks (again) Donkey Ote.

    This is how I went about trying to copy, by double clicking on it, a single cell within the range P7:P78 to pasting it in cell C43 on the same sheet:

    Please Login or Register  to view this content.
    Needless to say, it didn't work. Nothing happens. Can anyone advise me where I am going wrong,

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: On click within a range, copy and paste cell

    The BeforeDoubleClick event by default allows only for single cell selection so in truth the code can be condensed

    Please Login or Register  to view this content.
    Note that in the above you are always copying the value to C43 (overwriting what was there previously) - this requirement is implied by earlier code.

    (the Cancel line cancels the double click so as to prevent you from going into edit mode in the Target cell)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1