Computing.Net > Forums > Office Software > Excel Macros

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel Macros

Reply to Message Icon

Name: kite_boy
Date: January 19, 2009 at 08:42:18 Pacific
OS: Windows XP
CPU/Ram: P4 (2.26GHZ) 1GB RAM
Product: Dell DIMENSION
Subcategory: Microsoft Office
Comment:

Hello. Grateful for any help with the following task (I'm using Excel 2003).

I have 1200+ individual workbooks each containing two worksheets. The workbooks are all identical in format, but contain different data. For background info, each workbook contains details of the composition of individual waste streams. The data was extracted from a database that I do not have access to.

Worksheet 1 of each of the 1200+ workbooks is called "DataSheet" and consists of two columns and 187 rows. Column A contains the various headings and column B is the good stuff that I need to copy. The data is a combination of text (some >256 characters) and numbers.

I would like to combine the data from all 1200 "DataSheet" worksheets into one single worksheet within a new master workbook. The operation would therefore seem to require a transpose function too. That would leave me with a lovely table, with some 1200+ rows (one for each workbook / waste stream) and 187 columns across for the headings.

Ultimatley I need to to the same process for the second worksheet in each of the 1200+ workbooks, but although the data is arranged differently within this worksheet I'm guessing that I could adapt the first macro accordingly.

Hope this makes sense (it does to me, but that's not always a good sign!)



Sponsored Link
Ads by Google

Response Number 1
Name: orange
Date: January 20, 2009 at 09:44:20 Pacific
Reply:

First let me say I am not very familiar with Excel. Your problem is interesting.

I did do a little research to create a script that will (for a given workBook) transpose your worksheet "Datasheet"
such that your Headings ColA are laid out across the top, and your "Goodstuff" ColB
is placed in row 2 under the appropriate Heading.
This preserves your ColA and ColB, leaves ColC (as a placeholder for your Workbook name), and places your transposed data in Columns D onward.

It is only a start but may give you some ideas.

Note my Test is only using 12 rows of data, but the script is generic (I think).

Heres the script
[co-----
' Procedure : GenericTranspose
' Author : jed
' Date : 1/20/2009
' Purpose : Take a list of entries in column A and B
' starting in Row A1 and
' transpose these into row 1 starting in Column D
' Column B is moved to row 2 starting in column D
' Note Column C is left as a placeholder for the eventual Workbook ID
-
'
Sub GenericTranspose()
Dim rng As Range
Dim i As Long
Dim j As Long
Dim v1 As Long
Set rng = Cells(Rows.Count, 1).End(xlUp)
v1 = rng.Row
For j = 1 To 2
For i = 2 To rng.Row Step v1
Cells(j, "D").Resize(j, v1).Value = _
Application.Transpose(Cells(i, j).Resize(v1 + 2, j))
If j <> 1 Then
Cells(j, "C").Value = "WorkbookID" 'this is where Workbook Id would go
End If

Next i
Next j
End Sub

[/code]


0
Reply to Message Icon

Related Posts

See More


Excel list input Importing a .pst file int...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Excel Macros

Run Excel Macro as Automated Task on Server www.computing.net/answers/office/run-excel-macro-as-automated-task-on-server/9661.html

Excel Macro read and process CSV www.computing.net/answers/office/excel-macro-read-and-process-csv/3820.html

Excel macro www.computing.net/answers/office/excel-macro/4051.html