Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Next question, um problem...

27 views
Skip to first unread message

Bart

unread,
Mar 22, 2003, 9:07:43 PM3/22/03
to
First of all, thanks to everyone who has helped me out so far. This group
seems to have a very good attitude. Maybe I'm just too used to the "alt"
groups. This is rather refreshing.

With your help I have managed to create unique files for any individual in
the database. Now... let's say that I made 20 unique files (could be any
number, depending on the manager's load). These 20 unique files are saved
in a specific folder so that they can be viewed individually. That is good
enough for me, but I'm certain that the next demand will be to combine these
files into a single workbook so they can select tabs at the bottom (where
the "sheets" are listed). How do I get these files into the tabs?

Bart


John Wilson

unread,
Mar 22, 2003, 8:21:59 PM3/22/03
to
Bart,

Easiest way...manually....
Open all the workbooks simultaneously.
Windows/Arrange/Tiled
Make sure that all the tabs in each of the workbooks are uniquely named.
Drag them one at a time into a common workbook.
Use the Ctrl key to "add" them as opposed to "moving" them.
(the little + sign should appear)

John

Cecilkumara Fernando

unread,
Mar 23, 2003, 3:20:09 AM3/23/03
to
Bart,
This macro will copy the first sheet of all the .xls files in
"C:\My Documents\xltest" folder to a workbook named "Cook1.xls"
and name the each sheet after the original file name.
HTH
Cecil

Sub CopySheets()
Dim x As Integer
Dim FName As String
Dim MyPath As String
Dim oldname As String
Dim newname As String
Dim ws As Worksheet
x = Workbooks("Cook1").Sheets.Count

'the workbook that take sheets from other workbooks
'should be in a separate directory to avoid conflict
'so change the reference to the dir where the files are
ChDir "C:\My Documents\xltest"
Application.ScreenUpdating = False

'Set the path
MyPath = "C:\My Documents\xltest\"

'Find the first excel file
FName = Dir(MyPath & "*.xls")

'Stop loop when no more excel files
Do While Len(FName) > 0

'open the file and reference the first sheet
Set ws = Workbooks.Open(FName).Worksheets(1)

'give the name of the file and Copy to Cook1.xls
oldname = CStr(ws.Name)
newname = CStr(Left(CStr(FName), Len(CStr(FName)) - 4))
With ws
.Name = newname
.Copy After:=Workbooks("Cook1.xls").Sheets(x)
.Name = oldname
End With

x = x + 1

'Close the file
ws.Parent.Close False

'Find the next excel file
FName = Dir()

Loop

Set ws = Nothing

Application.ScreenUpdating = True

End Sub

"Bart" <so...@spamsucks.com> wrote in message
news:BF7fa.620$bJ...@fe07.atl2.webusenet.com...

0 new messages