+ Reply to Thread
Results 1 to 5 of 5

Add multiple ranges to an array then paste the data

  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Add multiple ranges to an array then paste the data

    Hello,

    I am new to arrays so this may sounds stupid but I'll go for it. The attached workbook is a test data dump I receive on a monthly basis that includes more columns than I need and I must format it. My plan is to loop through the top row that includes the title descriptions and search for specific column names. If a name matches then I set the range of the column area. Since there are a number of columns I figured I would loop through and add the ranges to an array and at the end paste just the columns I want to another location (for example sheet2 range A1 for instance.

    Can this be done? I would perfer to do it this way and not delete column.

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Add multiple ranges to an array then paste the data

    This will do what you want without all that hardcoding of titles. Instead, on sheet2, put the titles you want to collect in row 1, in any order at all. Then run this macro... it will find the exact same titles on SHeet1 and copy in the found data.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Add multiple ranges to an array then paste the data

    Hi ttd,

    Do you want to do this with a formula or a macro solution?

    A simple formula approach would be to put the Column Headings you want on row 1 of Sheet 2, and use HLOOKUP(), copying this formula down as far as you need to.

    eg. =HLOOKUP(A$1,Sheet1!$B$10:$AH$19,ROW(),0)

    Extract Data for ttd.xlsm

    I hope this helps, please let me know!

    Regards,

    David

    If this has been of assistance, please advise. A little thanks goes a long way.
    - Please click on the *Add Reputation button at the bottom of helpful responses.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".

    If several people have responded, when you reply please make it clear WHO you are responding
    to by mentioning their name.

  4. #4
    Registered User
    Join Date
    09-06-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Add multiple ranges to an array then paste the data

    Thank you Jerry. For my own knowledge could you have added the hardcoded ranges to an array and then paste everything to another workbook or sheet?

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Add multiple ranges to an array then paste the data

    Yes, of course, anything is possible. More advanced coders do everything in memory and arrays choosing to touch the spreadsheet only twice, once to move all the data into memory for manipulation, and once to write it all out at once time. Those guys are marvels.

+ 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] Need help with macro to copy and paste data from multiple ranges to new sheet
    By chicolocal in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2013, 07:48 PM
  2. Paste multiple ranges by Inputbox and paste it on one slide in powerpoint
    By irfanparbatani in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:32 PM
  3. copy paste data with multiple selected ranges from sheet to sheet
    By sivdin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2011, 02:45 PM
  4. Copy and Paste Ranges As Array From One WB to Another
    By jasono in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2011, 05:18 PM
  5. select variables ranges, copy to array, paste the array in new workbook
    By Mathew in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-01-2005, 05: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