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).UsedRange.Copy
ask.Activate
ask.Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Range("a1").Select
Selection.PasteSpecial xlValues
ask2.Close
End If
Next fil
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

On Thu, Nov 3, 2011 at 1:06 PM, <chhajersand...@gmail.com> wrote:

> **
> My files are saved in .xls format. But I am working in .xlxs.
>
>
> Sandeep Chhajer.
> Sent on my BlackBerryŽ from Vodafone
> ------------------------------
> *From: * ashish koul <koul.ash...@gmail.com>
> *Sender: * excel-macros@googlegroups.com
> *Date: *Thu, 3 Nov 2011 13:04:02 +0530
> *To: *<excel-macros@googlegroups.com>
> *ReplyTo: * excel-macros@googlegroups.com
> *Subject: *Re: $$Excel-Macros$$ Need to copy of 1st sheet of every
> workbook in a single work book
>
> in which format ur files are saved  .xls or xlsx
>
>
>
> On Thu, Nov 3, 2011 at 11:56 AM, sandeep chhajer <chhajersand...@gmail.com
> > wrote:
>
>> Dear Ashish,
>>
>> I have copied it but when i am running the code it showing error msg pls
>> help.
>>
>> On 3 November 2011 10:53, ashish koul <koul.ash...@gmail.com> wrote:
>>
>>> 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
>>>
>>
>>
>>
>> --
>> Regards,
>> Sandeep Kumar Chhajer.
>> Ph. no: 07498171901
>>            09339549906
>>
>> Wish you all happy new Year 2011.
>>
>>  --
>> 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
>
> --
> 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