+ Reply to Thread
Results 1 to 6 of 6

Copy/Paste Discontiguous columns

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Copy/Paste Discontiguous columns

    I'm trying to copy only the first and last columns from a table into a new sheet, where I want to paste them side-by-side, and am having trouble trying to figure out the context.My code is below. It works, except that instead of copying ONLY Columns 1 and 7, it copies the whole range and pastes it in. Any help straightening out my code is greatly appreciated.
    Please Login or Register  to view this content.
    Last edited by Mordred; 08-30-2011 at 01:05 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Copy/Paste Discontiguous columns

    Try this instead:
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Copy/Paste Discontiguous columns

    Stephen,

    Your code works, but I don't understand why. It seems to me that these three lines all say the same thing, but yours only copys the two columns in question, and the other two copy also the intervening columns. What's the secret to only capturing those two? Also, ideally I'd like to only copy the used range in each column, not the entire column. BTW, "LastRow" below is actually the last Data row, above the Totals, which is why I have the "+1".
    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Copy/Paste Discontiguous columns

    Re your first one, this will work:
    Please Login or Register  to view this content.
    I had a nasty feeling you'd ask why. I'm not sure, Columns must be interpreted along the same lines as the Cells property would be?

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Copy/Paste Discontiguous columns

    Maybe somebody else will tell us? But if not, thanks so much for getting my code going.

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Copy/Paste Discontiguous columns

    My pleasure. No doubt others here will know precisely why one works and the other doesn't.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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