Sub copy_first_sheet_from_different_workbooks_to_single()
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Dim fld As Object, fil As Object
Dim ask As Workbook, ask2 As Workbook

With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Choose the folder"
.InitialFileName = "c:\"
.Show
End With
fldpath =
Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & "\"
Set fso = CreateObject("scripting.filesystemobject")

Set fld = fso.getfolder(fldpath)

Set ask = Workbooks.Add

For Each fil In fld.Files
If UCase(Right(fil.Path, 4)) = UCase(".xls") Or UCase(Right(fil.Path, 5)) =
UCase(".xlsx") Then
Set ask2 = Workbooks.Open(fil.Path)
ask2.Sheets(1).Copy After:=ask.Sheets(Sheets.Count)
ask2.Close

End If
Next fil

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

On Wed, Nov 2, 2011 at 3:43 PM, mrinal saha <mris...@gmail.com> wrote:

> Hi Sandeep,
>
> Save this attachment in the folder where you have all the workbooks and
> try to run the macro (Button) on page 1 of this file.
>
> Hope this helps,
>
> Mrinal
>
> On Wed, Nov 2, 2011 at 2:08 PM, <chhajersand...@gmail.com> wrote:
>
>> Dear all,
>>
>> I have many work book in a single folder. I need a macro which if I run
>> will copy the 1st sheet of every workbook in a single workbook (though as
>> separate sheet).
>>
>> Like if I have 2 workbook viz WB1 and WB2 then I want the 1st worksheet
>> of WB1 as 1st worksheet in a new workbook (say WB3) and again 1st worksheet
>> of WB2 as 2nd worksheet of WB3.
>>
>>
>> Thanks in advance.
>> Sandeep Chhajer.
>> Sent on my BlackBerryŽ from Vodafone
>>
>> --
>> FORUM RULES (925+ members already BANNED for violation)
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>>
>> 2) Don't post a question in the thread of another member.
>>
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>>
>> 4) Acknowledge the responses you receive, good or bad.
>>
>> 5)  Cross-promotion of, or links to, forums competitive to this forum in
>> signatures are prohibited.
>>
>> NOTE  : Don't ever post personal or confidential data in a workbook.
>> Forum owners and members are not responsible for any loss.
>>
>>
>> ------------------------------------------------------------------------------------------------------
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>
>  --
> FORUM RULES (925+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>



-- 
*Regards*
* *
*Ashish Koul*
*http://www.excelvbamacros.com/*


P Before printing, think about the environment.

-- 
FORUM RULES (925+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to