+ Reply to Thread
Results 1 to 11 of 11

Problem with Macro to copy and paste a selection

  1. #1
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    568

    Problem with Macro to copy and paste a selection

    Hi Guys,


    I am trying to come up with a macro that copies a selection from one workbook to another.

    The macro should firstly select the range of filled data as shown here

    1.png

    and then copy and paste it to the end of my other workbook as shown here

    2.png


    Thank you for your help !

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Problem with Macro to copy and paste a selection

    Try this - amend file name, path, worksheet names

    Please Login or Register  to view this content.
    Last edited by kev_; 04-14-2017 at 09:17 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    568

    Re: Problem with Macro to copy and paste a selection

    Thank you very much ! It works !

    However, if my workbook (FileToPasteTo) is already open, then the macro gives me an error.

    Can this be fixed ?

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Problem with Macro to copy and paste a selection

    Try amended VBA below

    If the file is already open you may not want to close it

    replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    568

    Re: Problem with Macro to copy and paste a selection

    Thanks again !

    Now I get the warning that the Workbook "FileToPasteTo" is already open and that re-opening it might cause loss of data. I do not want to re-open it, if it is already open. I want to paste in in the open workbook. If it isnt open, then the Macro should open it.

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Problem with Macro to copy and paste a selection

    Please paste your code into reply
    Then select the whole code and click on # icon (to include code tags)
    thanks

  7. #7
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    568

    Re: Problem with Macro to copy and paste a selection

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    568

    Re: Problem with Macro to copy and paste a selection

    btw, Cheers to Cornwall We always loved it there, esp. Mawgan Porth

  9. #9
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    568

    Re: Problem with Macro to copy and paste a selection

    Duh, i think i found the error ! My bad !

  10. #10
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Germany
    MS-Off Ver
    365
    Posts
    568

    Re: Problem with Macro to copy and paste a selection

    Please Login or Register  to view this content.
    had to be replaced with my workbook name

    thanks muchly kev_

  11. #11
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Problem with Macro to copy and paste a selection

    You are welcome and of, course welcome to visit Cornwall again
    Thanks for the rep

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy And Paste Range on diffrenct sheet Selection problem Solved by : sixthsense
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-02-2014, 03:43 AM
  2. Problem with Selection find, offset, copy & paste Macro
    By MDResearcher in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-21-2011, 05:51 PM
  3. Macro to copy a selection, paste it in a new workbook then loop
    By AK262007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-06-2010, 06:35 AM
  4. Macro paste problem & date selection
    By c_mei83 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2009, 02:37 AM
  5. Problem with Range,Selection, Copy and Paste
    By ljunggrenus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2007, 07:19 AM
  6. Replies: 3
    Last Post: 02-20-2006, 12:55 PM
  7. macro to copy selection and paste special as picture in word
    By rabbi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-03-2005, 09:29 PM

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