+ Reply to Thread
Results 1 to 7 of 7

Copy across 9 columns of source data into 9 columns of an output table

  1. #1
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    30

    Copy across 9 columns of source data into 9 columns of an output table

    I have a spreadsheet with a source tab that has columns of different types of data, each named with a title at the top. I wanted to filter out the columns involving 'fuel cards', of which there are 9 different types (all labelled with 'fuel cards' appearing in the title, but with some slight variation).

    I am looking for some way for this data to copy across to a table with the 9 columns reproduced on a separate tab, with new data added in the table, below the old data.

    The relevant data is in red in the example file. I was hoping to add a new batch of data columns to the source tab each day. This would be added in new columns to the right of the old ones, and mixed among it will be other types of data that I wanted the formula to ignore.

    So the intention is to have the 'fuel cards' tab set up to collect any relevant new data from the inputs tab, and add it to the table, with new rows of data beneath the existing data.

    I was hoping that it might be possible to have a formula in the final table that looks for the correct columns and copies the data across, but which could be changed slightly for each column of the table (to collect the specific column in question). Ideally it could look for the exact text of the column title, and use that to identify the data to copy across.

    My original idea was to use the SMALL function or maybe HLOOKUP to identify the correct columns, but I do not know exactly how to execute it, in terms of getting the data to copy into the table beneath the old data.

    Thank you very much in advance for any help.
    Attached Files Attached Files
    Last edited by nunez100; 01-11-2019 at 12:39 PM.

  2. #2
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    282

    Re: Copy across 9 columns of source data into 9 columns of an output table

    I don't believe Excel can filter out columns, just rows.

    You can do this with a custom view. Just hide the Fuel Card Columns then select Custom Views from the Workbook section of the View tab, select Add, and save the view with a name like "Hide Fuel Card". You may want to save your normal (unhidden Fuel card) view as "Normal" to quickly get back to that.
    Last edited by gjcase; 01-11-2019 at 03:55 PM. Reason: wrong thread by accident

  3. #3
    Valued Forum Contributor
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    969

    Re: Copy across 9 columns of source data into 9 columns of an output table

    If you maintain the current format of your table then this might work. You can assign it to a Form Control button and run it when you complete your monthly entries.
    Please Login or Register  to view this content.
    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.

  4. #4
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Copy across 9 columns of source data into 9 columns of an output table

    Thank you for your responses.

    Gjcase, I will use your suggestion if I cannot get a formula to work, but I am really hoping that it is possible with a formula.

    JLGWhiz, is your solution VBA code? I am sorry to say that I do not know how to use that, but I could look into it if there is no other way.

    I have been reading some more, and I thought that if it were possible with a formula, then maybe a two way lookup with INDEX and MATCH could be combined with the SMALL function, but I am not certain of how to put it all together.

    I have attached a new version of the example, with just one data set, to make the question as simple as possible. The relevant source data (inputs tab), and the desired output data (Fuel cards tab), are both in red.

    Many thanks again for your responses.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    969

    Re: Copy across 9 columns of source data into 9 columns of an output table

    Based on how your data is laid out on the Inputs sheet, I think you will need to use VBA to do what you want. It is easy to use. Your security needs to be set to allow access to VBA. This is a one time action. Then the Workbook needs to be saved as a macro enabled (.xlsm) workbook. To install the code, press Alt + F11. If the large pane in the editor window is dark, click 'Insert' on the editor tool bar, then click 'Module'. This is also a one time action. When the large pane brightens, then paste the code into it. You can run the code from the Excel window by pressing Alt + F8, click on the macro name and then click the 'Run' button on the dialog box that popped up. Or, you can assign the macro to a button by going to the Developer tab on the ribbon, click insert under that tab's toll bar which will display both the Form Controls toolbox and the Active-X toolbox. Click on the button in the Form Controls toolbox then move the crosshairs (+) pointer to where you want the button to show on your screen and left click. A dialog box will appear with the option to assign a macro. Click on on 'Assign Macro', Click on the Macro name, Click OK. The button should not activate the macro. Save the file. Now when you need to copy the data, jjust click the button.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 2000/3/7/10/13/16
    Posts
    45,986

    Re: Copy across 9 columns of source data into 9 columns of an output table

    You may be able to do this with a Pivot Table.

    Highlight the whole table
    Click Insert/PT/New sheet
    drag Fuel Cards - Registration to "rows"
    drag Fuel Cards - Registration2 to "rows"
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Copy across 9 columns of source data into 9 columns of an output table

    Okay, I have followed your instructions JLGWhiz, and the macro works. Amazing! Thank you very much for this advice!

    I wonder if you noticed the second set of 'fuel cards' data in the inputs tab (also in red)? For some reason the macro seems to only pick up one of the data sets.

    It picks up the one starting in column AE, but not the one starting in column H. Perhaps I am not doing it correctly, but I think I followed all of the instructions.

    Thank you again for this!

    Regards

+ 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