Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Transpose 100 sheets in a directory automaticaly

Hello,

I will be receiving 100 or more xls per month which have rows as fields and
columns as cases/individuals/records, the opposite of standard db structure.

How would I go about writting a script that would open each of these and
transpose it without me doing them one by one? Their names will vary from
month to month.

Thanks in advance,

John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Transpose 100 sheets in a directory automaticaly

Hi John

Here is a solution which will open all of the xls files in a
designated directory. It assumes the sheet with the data on it is the
active sheet, it assumes the data commences in A1. It will copy the
current region, place a new worksheet in the book and paste the data
in the correct format (transposed). It will then save the workbook
and move onto the next book in the folder.

You will have to change the folder path. If you want this to be more
in line with your expectations can you please give more detailed
information. What is the sheet name of the workbook which you want
the data transposed from, what cell does the data commence in, are all
workbooks identical? Will the files be saved in a dedicated
directory. Where do you want the data transposed to - the sheet where
the data is on or a new sheet.

Anyways good luck with it.

Take care

Marcus

Option Explicit
Sub Open_Transpose()

Dim oWbk As Workbook
Dim sFil As String
Dim sPath As String
Dim twbk As Workbook
Dim strFullName As String

Application.DisplayAlerts = False
Application.ScreenUpdating = False

sPath = "P:\Finance\Integrated systems\Freight Business Plan
\Working Copies\Test" 'Chang to suit.
ChDir sPath
sFil = Dir("*.xls") 'All Excel files in folder can change this to
be more specific.

Do While sFil < "" 'will start LOOP
strFullName = sPath & "\" & sFil
Workbooks.Open Filename:=(strFullName), UpdateLinks:=0
Range("A1").CurrentRegion.Copy
Worksheets.Add
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False, Transpose:=True
ActiveWorkbook.Close SaveChanges:=True

sFil = Dir
Loop ' End of LOOP

End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy sheets to mulitple workbooks in a directory Greg[_37_] Excel Programming 2 March 31st 09 12:22 PM
excel transpose and references to cells in other sheets [email protected] Excel Discussion (Misc queries) 2 July 18th 08 03:34 PM
How do I copy all cell data between sheets automaticaly? biddersdv Excel Discussion (Misc queries) 2 September 14th 06 09:39 PM
listing all sheets in all workbooks in a directory Todd Huttenstine Excel Programming 3 March 2nd 06 03:29 PM
listing all sheets in all workbooks in a directory Todd Huttenstine Excel Programming 2 February 28th 06 01:30 AM


All times are GMT +1. The time now is 10:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"