+ Reply to Thread
Results 1 to 3 of 3

Error Handling Help - Skip .Copy if no visible cells

  1. #1
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Error Handling Help - Skip .Copy if no visible cells

    I am doing some copy pasting in VBA based on autofilter, sometimes the data is empty (all rows / data hidden) which will throw an error of course.

    I put in error handling but the problem is if the user had anything on their System clipboard this ends up getting pasted in the next step.

    My solution idea was to just have one blank cell copied whenever there was an error however my Error handling seems to be running both steps (ie, running the errorhandling code even when there was not an error)

    Here's one way I tried to solve it:
    Please Login or Register  to view this content.
    When there is not an error it's doing the Selection.SepcialCells(xlCellTypeVisible).Copy AND also the Range("A1000").Copy, not sure why.

    There's probably an easier way to say if there are no visible cells, just skip the .Copy part of the code?

    Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,958

    Re: Error Handling Help - Skip .Copy if no visible cells

    For the dual copy - you need an "Exit Sub" before the endProc: label

    Anyway, try the code like this:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Error Handling Help - Skip .Copy if no visible cells

    You are the best, that worked, thank you!

    Also: I am dumb for not putting Exit Sub =D

+ 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] If visible cells are empty, then skip to the next procedure?
    By mfusfw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-20-2022, 05:24 PM
  2. Replies: 4
    Last Post: 10-21-2020, 05:43 AM
  3. Replies: 0
    Last Post: 07-07-2020, 03:45 AM
  4. Copy Visible Date and Paste into Visible Cells only
    By vikas_newports in forum Excel General
    Replies: 14
    Last Post: 07-01-2020, 01:43 PM
  5. [SOLVED] Copy/Pasting Values from visible cells (using autofilter) to visible cells
    By evakotsi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2012, 07:49 AM
  6. Copy Visible cells and paste values only to visible target cells
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2010, 04:09 AM
  7. Copy only Visible cells to another sheet in Macro? Runtime 438 error?
    By nbaj2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-18-2006, 11:30 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