Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Copy worsheet from different files in to one file

Hi,

The situation is, I have 25 excel files in my C:/ drive.

I need to copy first worksheet named as "Fullrecon" from all 25 excel files
into one excel file.

In the new file, I need to name each worksheet as one, two, three.. so on.

This task is very important for me. I am not so good at coding. Please help
me achieve this. Thanks a lot for the help.

Thanks
Boss
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Copy worsheet from different files in to one file

Changge XLSdirectory to match whatever directory you are using

Sub copysheets()

XLSDirectory = "C:\temp\test\"

Dim Runname As String
Dim Index As String

First = True
Do

If First = True Then
XLSFileName = Dir(XLSDirectory & "*.xls")
First = False
Else
XLSFileName = Dir()
End If

If XLSFileName < "" Then

Workbooks.Open Filename:=XLSDirectory & XLSFileName
Set oldbk = ActiveWorkbook
With ThisWorkbook
oldbk.Sheets("Fullrecon").Copy _
after:=.Sheets(.Sheets.Count)
.Sheets("Fullrecon").Name = "Sheet" & .Sheets.Count
oldbk.Close
End With
End If
Loop While XLSFileName < ""

End Sub

"Boss" wrote:

Hi,

The situation is, I have 25 excel files in my C:/ drive.

I need to copy first worksheet named as "Fullrecon" from all 25 excel files
into one excel file.

In the new file, I need to name each worksheet as one, two, three.. so on.

This task is very important for me. I am not so good at coding. Please help
me achieve this. Thanks a lot for the help.

Thanks
Boss

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Copy worsheet from different files in to one file

Hi Joel,

Thanks for the code, but it gave me a error.

Just FYI the 25 worksheets contain many worsheets, the first worksheet of
all is named as "fullrecon"

Please help me to finish the task.

Thanks
Boss


"Joel" wrote:

Changge XLSdirectory to match whatever directory you are using

Sub copysheets()

XLSDirectory = "C:\temp\test\"

Dim Runname As String
Dim Index As String

First = True
Do

If First = True Then
XLSFileName = Dir(XLSDirectory & "*.xls")
First = False
Else
XLSFileName = Dir()
End If

If XLSFileName < "" Then

Workbooks.Open Filename:=XLSDirectory & XLSFileName
Set oldbk = ActiveWorkbook
With ThisWorkbook
oldbk.Sheets("Fullrecon").Copy _
after:=.Sheets(.Sheets.Count)
.Sheets("Fullrecon").Name = "Sheet" & .Sheets.Count
oldbk.Close
End With
End If
Loop While XLSFileName < ""

End Sub

"Boss" wrote:

Hi,

The situation is, I have 25 excel files in my C:/ drive.

I need to copy first worksheet named as "Fullrecon" from all 25 excel files
into one excel file.

In the new file, I need to name each worksheet as one, two, three.. so on.

This task is very important for me. I am not so good at coding. Please help
me achieve this. Thanks a lot for the help.

Thanks
Boss

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Copy worsheet from different files in to one file

Joel,

It's working perfectly.
Its was my mistake "Full recon" has a space between.

I just changed the name. Its working perfectly.

Thanks a lot for your help.
I apologise for the confusion.

Thanks
Boss

"Boss" wrote:

Hi Joel,

Thanks for the code, but it gave me a error.

Just FYI the 25 worksheets contain many worsheets, the first worksheet of
all is named as "fullrecon"

Please help me to finish the task.

Thanks
Boss


"Joel" wrote:

Changge XLSdirectory to match whatever directory you are using

Sub copysheets()

XLSDirectory = "C:\temp\test\"

Dim Runname As String
Dim Index As String

First = True
Do

If First = True Then
XLSFileName = Dir(XLSDirectory & "*.xls")
First = False
Else
XLSFileName = Dir()
End If

If XLSFileName < "" Then

Workbooks.Open Filename:=XLSDirectory & XLSFileName
Set oldbk = ActiveWorkbook
With ThisWorkbook
oldbk.Sheets("Fullrecon").Copy _
after:=.Sheets(.Sheets.Count)
.Sheets("Fullrecon").Name = "Sheet" & .Sheets.Count
oldbk.Close
End With
End If
Loop While XLSFileName < ""

End Sub

"Boss" wrote:

Hi,

The situation is, I have 25 excel files in my C:/ drive.

I need to copy first worksheet named as "Fullrecon" from all 25 excel files
into one excel file.

In the new file, I need to name each worksheet as one, two, three.. so on.

This task is very important for me. I am not so good at coding. Please help
me achieve this. Thanks a lot for the help.

Thanks
Boss

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 File Formulas between Files w/o the link PJ in CO Excel Worksheet Functions 3 December 12th 07 05:50 PM
Enter data in one worksheet and have it copy to another worsheet JimG Excel Discussion (Misc queries) 0 September 13th 07 01:50 AM
Divide worsheet and save as separate files Colin Hayes Excel Worksheet Functions 0 June 28th 05 09:42 PM
Trouble saving a worsheet to a file using macros. phoenixx153 Excel Programming 3 January 22nd 05 09:05 PM
Copy a range from different worksheets and place in another worsheet unplugs[_43_] Excel Programming 0 July 5th 04 03:51 AM


All times are GMT +1. The time now is 01:10 AM.

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"