List All Sheets Names From Multiple Workbooks & Copy Transpose Certain Columns
Oct 7, 2009
this may or may not be easy for some of you but its driving me nuts. Here's what I need to do.
1.Create a new workbook
2.Cycle through multiple workbooks and all worksheets within each workbook (all in the same folder). All workbooks will have the same structure.
3.Take the worksheet names and put them in rows
4.Take the data from the first column (column A) from the first worksheet of the first workbook and put them across the top (i.e. transpose the data). The first column will be the same in all workbooks so it doesn't matter where I get it from.
5.Copy the data from column E from each worksheet and paste them in rows in the new workbook (again transpose) corresponding to each worksheet.
6. Perform simple mathematical calculations at the end of each row.
I expect to have approximately 26 workbooks with a total of 7000 worksheets. In the target workbook (i.e. the new one), I expect there to be 7000 rows (corresponding to the 7000 worksheets) and about 260 columns.
The only reason I need to transpose stuff is because Excel 2007 doesn't have 7000 columns.
Here's an example of what it would look like.
Example worksheet (Input)-
Col A Col E
Imagine another worksheet called LMN with the same ColA but different values in Col E.
ColA Columns B Column C Column D
Sheet 1/1/2004 1/8/ 2004 1/15/2004
ABC $25 $30 $15
LMN $xxx $yyy $zzz
writing a macro that could save me loads of time. In the attached file there are 2 separate sheets of data ( named "Elements Innovation" and "Dinttap") that I need copied, pasted, transposed and consolidated into one master sheet (named "Desired result"). Note that the fields that relevant cells are highlighted in yellow. In reality I'll have many (~100) of these sheets that I need the data extracted from, and the work looks like it can be automated using VBA to speed things up.
The easiest way I can describe the scenario I am trying to create, is to use a company list of personnel (my index) and to generate a time-sheet workbook per person based on a pre-populated template. This time-sheet is saved as the persons name and has the persons name entered into cell D:10
I have a workbook which contains two worksheets;
1) An Index sheet which contains a list of names that I wish to use in Q16 downwards (note the length of this list will vary each time I run this)
2) A "template" sheet which I wish to duplicate in new workbooks
3) A second "data" sheet that I wish to copy across in new workbooks
I need a macro that will take the "template" and "data" sheets and copy it into a new workbook, renaming each new workbook to each name in my Index sheet. I also want that same Name to be copied into cell reference D:10 of the "template" each time.
The end result is that I should have a series of new files generated and saved which are named the same as the Index list, with both the "Template" sheet and the "Data" sheet present, with the cell D:10 pre-populated with the Name provided in the "Template" sheet.
I have a created a main workbook with a macro that opens workbooks on a particular sheet from a list of workbook paths and filenames in the main workbook. The macro are suppose to copy the sheet and paste it into a sheet with a new name that I have defined from the list in the main workbook. I can get the macro to open the workbooks and close them. But I can't get the macro to copy the sheet into the main workbook.
I have attached the code and the workbook. I used slet_ark to delete previous sheet and hentark and henttekstfil to open the different workbooks.
The code I use are:
Public Sub Slet_ark() Dim ark() As Variant Dim Counter As Long Dim FirstSheet As Long Dim LastSheet As Long
I need to be able to extract particular named columns from multiple files and then populate them in a new excel workbook. Ideally, this would allow me to specify the file directory, the column of interest (based on standardized names), and then run the macro. If this could be done but I would need to have the excel workbooks open to extract the data, that's not a problem (not sure on this). In the multiple workbooks, the data of interest are all on worksheets that have the exact same name, and the column names in Row 1 of those worksheets are all consistently named the same.
Ideally, in the new workbook I need the Row1 column names to contain the source file name from which the data in each respective column came from (with what I'm needing to do all of the extracted data will be the same parameter, e.g., water quality pH values stored in columns from 20 excel files all in the same file directory). Attached are two examples of the many files I have in this format. The worksheet containing the data of interest is called "Station_Comprehensive_Cleaned". In this case, an example column to be extracted from the latter named worksheet in each example workbook and pasted into a new workbook (hopefully/ideally with the respective source workbook file name as the column name) is Column 34 called "Solids_Dissolved"
I have a folder with 250 files. Each of the file has only one column. I need to search the rows starting with "Party Name" and copy them in any one row. I want a macro either to copy the filtered results in the same file or a fresh workbook.
Column A row 1 ABCDE row 2 FGHI row 3 Party Name:Abcd row 4 JKLM row 5 nopq row 6 STUV row 7 Party Name:ryz row 8 Party Name:mno row 9 XYZ
I want the results as below:
Column A Column B Column C Column D row 1 ABCDE Party Name:Abcd Party Name:ryz Party Name:mno
I have a database output file where one of the columns contains managers names, often more than once. I want to apply an autofilter on manager name and then copy the result to another sheet or sheets. My criteria for the autofilter is a variable pointing to a list of names that at present I maintain by hand; a for-each-next loop then cycles through the names.
What I would like to do, before running the autofilter code, is to create the list of names via code. This would then automatically pickup names that are missing.
The code I have so far is below:
Public Sub find_managers() Dim managers1 As Range Dim names1 As Range Dim n1 As Variant Dim n2 As Variant
In my mind it should check the names in the unique list against the imported list and add any missing names.
1. I have a list of data (Collated Data) 2. For every row in collated data I want to export the cells into a corresponding cell in my predetermined workbook (TAF Form), i.e, Cell C1 on Collated data goes into Cell D3 on TAF Form, cell D1 to cell I3 etc etc 3. Once all cells in one row have been copied into the TAF Form I want that TAF Form to save as "TAF Form & Employee Name" (which would come from cell D3). 4. I then want "TAF Form & Employee Name" to close. 5. I then want the Macro to do the same thing for Row 2, copy the cells, save the form, close the form 6. I want to do this for every row that I have (which varies).
Is this possible? If you have any more questions in terms of what I need, don't hesitate to ask.
I have a workbook with multiple worksheets. First 4 tabs are the standard tabs and rest of the tabs are created based ona macro with the unique names. Now i want to create the separate workbook for each tab by its name and , date and time stamp in a C directory.
I have a workbook with many sheets labelled as mmm-yyyy. The constant columns in all the sheets are C,E,R,T, and U.
Is it possible to have a macro do the following: Add a sheet called Summary at the end of the workbook. From the last sheet of mmm-yyyy, copy columns C, E, and R to the Summary sheet. Copy columns T and U from all the other mmm-yyyy sheets to the Summary sheet. All the cells need to be centered.
I joined a file so that you guys can understand what my problem is! In test4.xls there is 4 sheets. The one named "End" should appear in a new workbook. So i'm trying to make a macro that will transform sheet A,B and C into the sheet "End" in a new workbook! i know i have to transpose the data, but i didnt find how! The problem is that the macro have to work for each month of any years(2006,2007,etc)! Anyone know how to do it?
I have a long column of data in column D (D2 to D8761) and I would like to sequentially select 24 cells at a time (D2:D25, D26:D49, D50:D73...D8738:D8761) copy them and paste them to another sheet as separate rows.
For instance, the selected data from Sheet 1, D2:D25, would be pasted/transposed to Sheet 2 B9:Y9. I would like the macro to loop so it would then select D26:D49 and paste/transpose to B10:Y10 and so on until it finishes transposing the final data group of D8738:D8761.
I'll add the macro that I recorded using the brute force method so perhaps you can have a better understanding of what I am trying to accomplish.
I would like to use VBA to search a folder and copy data from tabs within the excel files there. The data will be pasted to a tab of same name in the the main file. All the files are in the same format.
So far I have only managed to list the files in the folder using code I found on your site!
I have data spanning many files which are named with the date on which they were created (so there are 31 files for August). For example: PL080107, PL080207, PL080307, PL080407...)
I'm trying to compile all of my data into one workbook, and have the macro to append each file to a list. Now I need the macro to either OPEN each file, or ACTIVATE each file so that the rest of the Macro can grab the necessary data.
I say Open or Activate, because I can MANUALLY Open a full month's worth of files if it's easier code. If not, I would like it to open and close each workbook on its own.
I have over 7 month's worth, so opening 31 files 7 times is better than opening over 200 files individually!
I currently have a piece of code that opens all of the files in a folder that are called "*agent*", opens them and copies information. Now, these files come with numbers at the beginning which, are always the same. I only want to open certain files that begin with, for example, 801, 802, 803, 804, 805 and 806. How would I write this into my code? As you can see from the below code, it now looks for the files that all have "agent" in the name, but this is opening files that have that name but are not the right ones. Here is my current macro...
I hope this isnt as simple as putting "MyFile = Dir(MyFolder & "*801*", "*802*")" etc.
I have an problem transposing multiple columns into a table. Source data is organized in 3 columns - ID, Visit#, Date. What I need is a seet in which I'd have in Column A - and ID, in Row 1 a Visit type and Visit date would be populated in the table. See attached file. Since I'm handling about 50k datapoints a simple "paste special--->transpose" is a nightmare.
I'm trying to get a macro together that will take a set of workbooks that I've merged (using Ron de Bruin's RDBMerge add-in) and transpose all columns from B to HB into rows. Now, I know that each spreadsheet is 210 columns and 244 rows large and they are concatenated on one another. Attached is a brief example of what I am trying to go from and what I am trying to get to.