+ Reply to Thread
Results 1 to 4 of 4

PasteSpecial Causing "Range Not Found Error"

  1. #1
    Registered User
    Join Date
    05-13-2021
    Location
    Lithgow, Australia
    MS-Off Ver
    365
    Posts
    2

    PasteSpecial Causing "Range Not Found Error"

    Hi,

    I am getting this weird and random error. I have written the function below that takes a range, copies it and pastes as a picture in a range.

    Randomly, when it gets to pasteRange.PasteSpecial, it will throw an error that it can't find the range. If I enter debug it works perfectly.

    It is almost like it's going too fast for itself. It just need to chill for a minute and it finds the range.

    Has anyone else had this issue?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: PasteSpecial Causing "Range Not Found Error"

    Hi there,

    It's very difficult to debug your problem without access to your workbook, but I have seen comments like the following MANY times in this forum!


    Randomly, when it gets to pasteRange.PasteSpecial, it will throw an error that it can't find the range. If I enter debug it works perfectly.


    This problem can be caused by the "pasterange" variable referring to a Defined Name, but not being not fully-qualified - i.e. it does not include a reference to the worksheet. This means that the code will try to find the specified range on whichever worksheet happens to be active when the code is executed, rather than on the worksheet which you want to use.


    You should use a fully-qualified reference such as the following:

    Please Login or Register  to view this content.
    rather than:

    Please Login or Register  to view this content.

    Almost invariably, when you step through the code using the debugger, you select the intended worksheet before you start - hence no error condition occurs.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    05-13-2021
    Location
    Lithgow, Australia
    MS-Off Ver
    365
    Posts
    2

    Re: PasteSpecial Causing "Range Not Found Error"

    Well, don't I feel like a right goose.

    That is something I am very particular about for that very reason and here I haven't done it...

    I even set up the variables further up to do it and still didn't...

    Thanks mate. Really appreciate it. Let's hope that fixes it.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: PasteSpecial Causing "Range Not Found Error"

    Hi again,

    Many thanks for your feedback.

    Don't beat yourself up over it - we've all done that at some stage!

    You're welcome - glad I was able to help.

    Regards,

    Greg M

+ 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] This line of code is causing an error message "Autofilter method of range class failed"
    By hadleedog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-04-2018, 03:58 AM
  2. [SOLVED] If Not ActiveSheet.Range("A1").Value Like "apple" Then MsgBox "Error"
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-18-2014, 02:16 PM
  3. [SOLVED] Find expression causing "Subscript out of range" error
    By aseret in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-08-2013, 12:05 AM
  4. Replies: 3
    Last Post: 04-14-2013, 11:53 PM
  5. Replies: 2
    Last Post: 01-10-2013, 06:13 PM
  6. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  7. [SOLVED] "Pastespecial Method of Range Class Failed" while trying to Transpose
    By tenscourts in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2012, 02:37 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