+ Reply to Thread
Results 1 to 7 of 7

Copy/Paste problems

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Copy/Paste problems

    I am having unexpected problems copying and pasting.
    I cannot see a problem with the following code,

    Please Login or Register  to view this content.
    I have also split the Asterixed line by using SELECT / Selection.copy
    This showed that the error was thrown on the selection part of the line

    b is the column No of BDZ
    y is the row no of the copy range
    x = 3
    I have tried using R1C1 as well as the cells notation. This fails too at the Range,Copy part of the code.
    I originally had the error when using PasteSpecial (Which I will need to revert to)
    Can somebody help please
    John

  2. #2
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Copy/Paste problems

    I forgot to include the error message. It was 1004 Application or object defined error.
    John

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: Copy/Paste problems

    Please upload your sample file and explanation...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Copy/Paste problems

    When you write this:

    Please Login or Register  to view this content.
    Both the blue and red highlighted ranges refer back to the With ws1 block. You need:

    Please Login or Register  to view this content.
    or use a variable for Sheets("Sheet4").
    Rory

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Copy/Paste problems

    Firstly thank you, for your code works.
    Secondly though, I don't quite understand why. The blue range is preceded with "Sheets("Sheet4")". Has this no standing?
    John

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Copy/Paste problems

    No. Whenever you use a property preceded by a dot with no object qualifier, it refers back to the nearest With block (assuming there is one; if not, you get an error). In other words:

    Please Login or Register  to view this content.
    You qualified the Range call with a sheet, but not the two Cells ones.
    Last edited by rorya; 11-27-2020 at 12:43 PM.

  7. #7
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Copy/Paste problems

    Rorya
    Thanks for your explanation. I had not understood that implication when using dot. Of course one usually is referring to the With object, so no problem. I have had occasions though, when you need to refer to two objects only one of which is the with object, and now I know why. Many thanks for your help
    John

+ 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] Problems with copy paste
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2020, 01:06 PM
  2. Replies: 6
    Last Post: 07-27-2013, 09:02 AM
  3. Copy and Paste problems
    By fjsjr in forum Excel General
    Replies: 2
    Last Post: 09-28-2012, 04:27 PM
  4. VBA copy and paste problems
    By Sherpa21987 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2011, 11:33 PM
  5. copy and paste problems
    By paulplus_uk in forum Excel General
    Replies: 2
    Last Post: 06-03-2010, 05:09 AM
  6. copy paste problems
    By gpp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2008, 03:49 AM
  7. Copy - Paste problems
    By Guillermo in forum Excel General
    Replies: 0
    Last Post: 04-09-2005, 12:06 AM

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