+ Reply to Thread
Results 1 to 3 of 3

VBA to paste range skipping filtered rows & what is the range copy buffer called

  1. #1
    Registered User
    Join Date
    12-08-2017
    Location
    Minneapolis, MN
    MS-Off Ver
    Standard 2013
    Posts
    83

    VBA to paste range skipping filtered rows & what is the range copy buffer called

    Just had a great idea for a macro for something that always bugged me. When you paste a range over a filtered table, it will paste into the hidden rows. Why not VBA that away?

    What's the name of the paste buffer (the excel "clipboard") when you're copying a range versus copying inside a cell? If I know the name, I think i can work with this directly in VBA or do more research.

    I got the following code to work. This helps because I don't want the macro to select the range to copy. I want the person to have already selected it.

    Please Login or Register  to view this content.
    (I don't want to paste special. I just want to paste but there is no method in intellisense. pastevalues is fine for now)

    if I know the name of the "copy buffer object", I can see if it's a collection or list or if it can be parsed or split. Once it is split into a list, I can iterate through it and I think I can handle it there. I can just check for the visibility properties of rows. We'll cross that bridge when we get to it.

    (There's surprisingly little written about the two types of copy and paste in excel and the underlying mechanics. I don't meant the types of paste special. I mean copying a range vs copying in a cell.)

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA to paste range skipping filtered rows & what is the range copy buffer called

    You cannot copy a range and paste only part of it. Nor can you split the data on the clipboard to make it paste portions at a time. When you copy a range, It must be pasted into an area of the same number of contiguous rows and columns. Using the Union method or the SpecialCells method you can copy data from non contiguous ranges, however, VBA joins those ranges into one as part of the copy function and they will be pasted as a single range comprised of the numbers of columhns and rows created by the mehod used to define the copy range. Maybe this will help you to understand the mechanics of the copy and paste function.
    Last edited by JLGWhiz; 01-16-2020 at 07:36 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    12-08-2017
    Location
    Minneapolis, MN
    MS-Off Ver
    Standard 2013
    Posts
    83

    Re: VBA to paste range skipping filtered rows & what is the range copy buffer called

    Quote Originally Posted by JLGWhiz View Post
    You cannot copy a range and paste only part of it. Nor can you split the data on the clipboard to make it paste portions at a time. When you copy a range, It must be pasted into an area of the same number of contiguous rows and columns. Using the Union method or the SpecialCells method you can copy data from non contiguous ranges, however, VBA joins those ranges into one as part of the copy function and they will be pasted as a single range comprised of the numbers of columhns and rows created by the mehod used to define the copy range. Maybe this will help you to understand the mechanics of the copy and paste function.
    Cool, thanks for your clarifications.

    I just had an idea. I could create a new worksheet.

    Then paste on that worksheet.

    Then transfer cell values (not format!!) one by one through iteration (or maybe by populating an array), and by and range/row property criteria (e.g. ".hidden = false"). I think I can find a method that works with this.

    Then of course delete the dummy worksheet or workbook.

    There's always work around! At least I always want there to be.

    Gods, I swear VBA is the only thing keeping me sane at my job sometimes!
    Last edited by foxtrotter; 01-16-2020 at 09:36 PM.

+ 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. Replies: 3
    Last Post: 05-07-2017, 02:53 PM
  2. [SOLVED] 1 to copy only filtered records and 2 to paste into range ending by last row in next col
    By Ramzes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2017, 10:13 AM
  3. copy range from one sheet to another and then copy 5 times skipping ten rows
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-13-2015, 01:35 PM
  4. Copy paste filtered range with criteria using VBA
    By Jayant shettigar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-12-2014, 10:26 AM
  5. copy paste macros
    By rrk2008 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2014, 06:42 AM
  6. [SOLVED] Copy/Paste from a Filtered Range and Insert copied data NOT overwrite
    By Simon.Ward in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-12-2013, 11:14 AM
  7. [SOLVED] Copy first 4 rows of filtered range
    By Charles in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-22-2012, 03:02 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