+ Reply to Thread
Results 1 to 7 of 7

I need column data NOT in A,B,C,D order when copying to a new sheet.

  1. #1
    Registered User
    Join Date
    03-18-2015
    Location
    Detroit
    MS-Off Ver
    2013
    Posts
    78

    Question I need column data NOT in A,B,C,D order when copying to a new sheet.

    I am using the following piece of code from another workbook. It basically transfers some data from one sheet into another sheet.
    It works good in the other workbook because it copies data from certain rows/columns and pastes them (the first sheet has like 20 columns and I only need data from 4 of them). And it puts them in order.

    Problem is the original workbook I borrowed this from by default takes the first 4 columns (A,B,C,D) and transfers them to the target sheet the same way (A,B,C,D). With the new sheet I need column data NOT in A,B,C,D order


    Here is the original line in the code:
    Please Login or Register  to view this content.

    I changed it to this:
    Please Login or Register  to view this content.
    Problem is it still wants to bring those columns over in alphabetical cell column letter (A,B,I,K), when I need it in the order (A,I,K,B)



    Here is the entire code I am using.

    Please Login or Register  to view this content.
    Thanks
    Last edited by PitBoo; 06-20-2019 at 04:48 PM. Reason: Changed column letters

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: I need column data NOT in A,B,C,D order when copying to a new sheet.

    edit: disregard below - it will not return the row values correctly with the column array (rather it will repeat first row element); apologies

    if you only require values you could change tack a little, and leverage functionality of index - e.g.

    Please Login or Register  to view this content.
    Last edited by XLent; 06-21-2019 at 03:15 AM.

  3. #3
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: I need column data NOT in A,B,C,D order when copying to a new sheet.

    You could, of course, just copy each column in turn, i.e.:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-18-2015
    Location
    Detroit
    MS-Off Ver
    2013
    Posts
    78

    Re: I need column data NOT in A,B,C,D order when copying to a new sheet.

    Thanks for the reply,

    For this one it is throwing a Compile Error at the first av1

    Capture2.JPG


    This is how a put it together, I probably put something in the wrong spot.

    Please Login or Register  to view this content.
    I used the code in your second post below and it worked great, everything fell in line. The only two issues were that it brought over all of the conditional formatting rules from the first sheet and the A cell on the first sheet has drop down options and when it copied it pulled all of the drop down options for that cell.
    Everything copied over correctly but those were just two small things. That's why I took a second look at this code because you stated to use it if I only require VALUES, which would be ideal.


    Thanks again.

  5. #5
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: I need column data NOT in A,B,C,D order when copying to a new sheet.

    Re: 1st error - yes, if running Option Explicit (good practice) then you'd need to declare av1, i.e.

    Please Login or Register  to view this content.
    Re 2nd approach -- if you just want values you can use PasteSpecial etc or, making use of av1 (created per first example) you could use the below approach:

    Please Login or Register  to view this content.
    the above will not reset the formatting / validation already in place so if unwanted you'd need to remove first, as a one-off.
    Last edited by XLent; 06-21-2019 at 10:39 AM.

  6. #6
    Registered User
    Join Date
    03-18-2015
    Location
    Detroit
    MS-Off Ver
    2013
    Posts
    78

    Re: I need column data NOT in A,B,C,D order when copying to a new sheet.

    Ok this is what I am using now.


    Please Login or Register  to view this content.
    The only two issues are:
    1. Its copying over conditional formatting from the first sheet
    2. Its bringing along data validation drop downs from the first sheet.

    So I am assuming I would just need some sort of pastespecial code or something?

    Problem is I have tried to figure it out on my own with no luck (I can get by with modifying some code for the most part but creating anything new and I am at my limits of skill).


    I can LIVE with the above 2 issues if need be but would be grateful if someone could help me fix it.
    Last edited by PitBoo; 06-21-2019 at 04:28 PM.

  7. #7
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: I need column data NOT in A,B,C,D order when copying to a new sheet.

    So, without rewriting too much, and further to prior posts, you might try using the below:

    Please Login or Register  to view this content.
    as mentioned, you will need to clear any pre-existing (& unwanted) formatting/validation from 'wo cover' worksheet as the above code will simply clear & copy contents.

+ 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. Copying data from a column in one sheet to a row in another
    By richardintouch1978 in forum Excel General
    Replies: 1
    Last Post: 09-22-2018, 03:16 AM
  2. Replies: 1
    Last Post: 08-12-2018, 11:45 AM
  3. Replies: 1
    Last Post: 05-23-2013, 10:16 AM
  4. [SOLVED] Macro for copying data from one column in sheet 2 based on two criterias in sheet 1
    By baardings in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-13-2012, 01:50 PM
  5. [SOLVED] copying specific certain column data based on cell/column value to another sheet
    By arctic7 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-09-2012, 03:38 PM
  6. Replies: 1
    Last Post: 06-17-2011, 04:18 PM
  7. Replies: 1
    Last Post: 05-12-2007, 10:06 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