+ Reply to Thread
Results 1 to 5 of 5

SpecialCells.Copy when none to copy

  1. #1
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    371

    SpecialCells.Copy when none to copy

    I have a macro that filters data by certain criteria. Once the data is filtered, the data will than be copied and pasted to a different sheet. However, in the event that no data is filtered as it didn't match the criteria, I get an error in the copy code below as it states "No cells were found" Run-time-error '1004'

    Code:

    'Copy data to CR Table
    Sheets("EAS Dump").Range("H3:H4000").SpecialCells(12).Copy


    Is there a way that it will not error out and do nothing when there is no data...?

    Thanks

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

    Re: SpecialCells.Copy when none to copy

    This will step over it and carry on as if the error was not there:
    Please Login or Register  to view this content.
    This will end the sub-routine:
    Please Login or Register  to view this content.
    This allows you to step over some other code or to tell VBA what to do in the event of an error:
    Please Login or Register  to view this content.
    Last edited by kev_; 03-29-2017 at 02:21 PM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: SpecialCells.Copy when none to copy

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    371

    Re: SpecialCells.Copy when none to copy

    Thanks to all for a quick reply... the ErrHandling option worked best for my situation...

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

    Re: SpecialCells.Copy when none to copy

    Glad it helped.
    Don't forget to reset Error
    Thanks for rep and for marking thread as solved

+ 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] Change Copy to Copy & Mirror Image the Copy
    By mills49 in forum Excel General
    Replies: 5
    Last Post: 08-21-2014, 05:25 AM
  2. Save copy as, open copy, alter copy, save copy and close copy
    By tradinup2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-03-2013, 04:42 PM
  3. Replies: 3
    Last Post: 01-30-2013, 04:32 PM
  4. Using SpecialCells for multi-column same-row copy/pasting
    By evilgrinners in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-15-2013, 12:06 PM
  5. Macro to copy Dyanmic lists then copy sheet and clear the original data
    By twiggywales in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2012, 01:06 PM
  6. Copy one cell to an other but colors do not copy. While not using clipboard to copy.
    By chuckchuckit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2010, 03:08 AM
  7. EXCEL FILE a copy/a copy/a copy ....filename
    By ve in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 09-29-2005, 05:05 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