Here you go.
The technique it uses is a FileSystem object.
It creates a  SubFolder collection and processes each
folder in the Subfolder collection.
In each of these folders, it creates a Files collection
and processes each file in the collection.

Paul
'========================================================================================

Option Explicit
Global fso, RepRow, RepSheet
'========================================================================================

Sub NewSheetFolders()
    Dim stat, SubFolder, SubFolders, Folder
    Dim FolderName, Fldr
    '-----------------------------------------------------
    RepSheet = "File-List"
    RepRow = 1
    '-----------------------------------------------------
    Application.ScreenUpdating = False
    On Error Resume Next
    Set fso = CreateObject("Scripting.FileSystemObject")
    '-----------------------------------------------------
    ' Prepare Sheet for collecting data by clearing current contents
    '-----------------------------------------------------
    Sheets(RepSheet).Select
    Range("A2:Z65000").ClearContents
    '-----------------------------------------------------
    ' Beginning folder name
    '-----------------------------------------------------
    FolderName = "C:\temp\DataFiles"
    '-----------------------------------------------------
    'Begin Processing
    '-----------------------------------------------------
    stat = Get_ShtFolders(FolderName)
    '-----------------------------------------------------
    On Error GoTo 0
    Application.ScreenUpdating = True
    MsgBox "Finished"
End Sub
'========================================================================================

Function Get_ShtFolders(FolderName)
    Dim stat, SubFolder, SubFolders, Folder, ShtCnt
    Dim File, FileCollection, Ext
    '-----------------------------------------------------
    Set Folder = fso.GetFolder(FolderName)
    Set FileCollection = Folder.Files
    '-----------------------------------------------------
    ' Process each file in Folder
    '-----------------------------------------------------
    For Each File In FileCollection
        Ext = fso.getextensionname(File.Path)
        If (UCase(Left(Ext, 3)) = "XLS") Then
            stat = Get_File_Data(File.Path, File.Name)
        End If
    Next File
    '-----------------------------------------------------
    Set SubFolders = Folder.SubFolders
    '-----------------------------------------------------
    ' Process each SubFolder in Folder
    '-----------------------------------------------------
    If SubFolders.Count <> 0 Then
        For Each SubFolder In SubFolders
            stat = Get_ShtFolders(SubFolder.Path)
        Next
    End If
    Get_ShtFolders = ShtCnt
End Function
'========================================================================================

Function Get_File_Data(XLFullName, XLFileName)
    Err.Clear
    Workbooks.Open XLFullName, ReadOnly:=True, UpdateLinks:=False
    If (Not Err) Then
        RepRow = RepRow + 1
        ThisWorkbook.Sheets(RepSheet).Cells(RepRow, 1).Value = XLFileName
        ThisWorkbook.Sheets(RepSheet).Cells(RepRow, 2).Value = Sheets.Count
    Else
        MsgBox Err.Number & Chr(13) & Err.Description
    End If
    ActiveWorkbook.Close savechanges:=False
End Function
'========================================================================================


 



________________________________
From: Prathima R <prathima....@gmail.com>
To: excel-macros@googlegroups.com
Sent: Fri, February 11, 2011 7:49:00 AM
Subject: Re: $$Excel-Macros$$ Need Help


Paul as per below conversation the macro which you have can u please send me so 
that i customize from my  end.

Thanks,
Prathima


On Thu, Feb 10, 2011 at 10:55 PM, Paul Schreiner <schreiner_p...@att.net> wrote:

You've asked this question in an Excel VBA Macros user group.
>
>Do you not wish a VBA solution?
>
>Also, your initial question stated that you had multiple "sheets".
>This follow-up says "workbooks".
>
>So, the question is:
>are they multiple sheets in multiple workbooks?
>one sheet per workbook?
>
>also... 
>you need to give us more "setup" information.
>are all of the workbooks open?
>or do you want the macro to open them?
>How are the workbooks identified?
> Are they in a single folder?
> Are they in sub-folders beneath a single folder?
> Are you opening ALL excel files in the folder/subfolder?
> Or do you have a list of files to process?
>And...
> What constitutes "non-blanks"?
>   Are you counting rows of data?
>   are there columns that ALWAYS have data that defines a "record"?
>   Or are you counting the non-blank cells in the entire sheet? (doubtful)
>
>Oh.. and... what version of Excel are you using?
>
>
>What do you want to do with the information?
>
>I have a macro that will open all Excel files in a given folder and all 
>sub-folders.
>And for each file, count the number of non-blank cells in each sheet.
>Then, in the "report" file,
>list the file name of each file, the number of sheets and the number of 
records.
>
>I can give that to you and then you can customize it to fit your needs...
>
>Paul
>
>
>
________________________________
From: Prathima R <prathima....@gmail.com>
>To: excel-macros@googlegroups.com
>Sent: Thu, February 10, 2011 9:11:41 AM 
>
>Subject: Re: $$Excel-Macros$$ Need Help
>
>
>
>please advice in this concern as i am having around 20-30 workbooks where in 
>need to  count the number of Non-blanks in multilple sheets.
>
>Thanks,
>Prathima
>
>
>On Thu, Feb 10, 2011 at 7:23 PM, Prathima R <prathima....@gmail.com> wrote:
>
>
>>
>>Thanks for the response.
>>Here am trying to count the number of non-blanks in multiple sheets
>> 
>>
>>On Thu, Feb 10, 2011 at 6:32 PM, Paul Schreiner <schreiner_p...@att.net> 
wrote:
>>
>>Are you wanting to count the sheets
>>>or count the records/rows on all sheets?
>>>
>>>Sheets.Count
>>>
>>>gets you the number of sheets.
>>>
>>>For Sht = 1 to sheets.count
>>>    total = total 
>>>+ application.worksheetfunction.counta(sheets(sht).range("A1:A65000"))
>>>next Sht
>>>
>>>would loop through all sheets and count the number of non-blank cells in 
>>>column 
>>>"A".
>>>
>>>??
>>>
>>>Paul
>>>
>>>
>>>
>>>
________________________________
From: Prathima R <prathima....@gmail.com>
>>>To: excel-macros@googlegroups.com
>>>Cc: ashish koul <koul.ash...@gmail.com>
>>>Sent: Thu, February 10, 2011 6:21:43 AM
>>>Subject: $$Excel-Macros$$ Need Help
>>>
>>>
>>>
>>> 
>>>Hi,
>>>i have multiple sheets and i want to count the number of instruments in one 
>>>go, 
>>>with COUNTA am not able to get. I tried grouping the sheets but could't get 
>>>the 
>>>count of all sheets.
>>>need your suggestion
>>>Thanks,
>>>Prathima-- 
>>>----------------------------------------------------------------------------------
>>>
>>>Some important links for excel users:
>>>1. Follow us on TWITTER for tips tricks and links : 
>>>http://twitter.com/exceldailytip
>>>2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
>>>3. Excel tutorials at http://www.excel-macros.blogspot.com/
>>>4. Learn VBA Macros at http://www.quickvba.blogspot.com/
>>>5. Excel Tips and Tricks at http://exceldailytip.blogspot.com/
>>>
>>>To post to this group, send email to excel-macros@googlegroups.com
>>> 
>>><><><><><><><><><><><><><><><><><><><><><><>
>>>Like our page on facebook , Just follow below link
>>>http://www.facebook.com/discussexcel
>>>
>>>-- 
>>>----------------------------------------------------------------------------------
>>>
>>>Some important links for excel users:
>>>1. Follow us on TWITTER for tips tricks and links : 
>>>http://twitter.com/exceldailytip
>>>2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
>>>3. Excel tutorials at http://www.excel-macros.blogspot.com/
>>>4. Learn VBA Macros at http://www.quickvba.blogspot.com/
>>>5. Excel Tips and Tricks at http://exceldailytip.blogspot.com/
>>>
>>>To post to this group, send email to excel-macros@googlegroups.com
>>> 
>>><><><><><><><><><><><><><><><><><><><><><><>
>>>Like our page on facebook , Just follow below link
>>>http://www.facebook.com/discussexcel
>>>
>>
>-- 
>----------------------------------------------------------------------------------
>
>Some important links for excel users:
>1. Follow us on TWITTER for tips tricks and links : 
>http://twitter.com/exceldailytip
>2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
>3. Excel tutorials at http://www.excel-macros.blogspot.com
>4. Learn VBA Macros at http://www.quickvba.blogspot.com
>5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>
>To post to this group, send email to excel-macros@googlegroups.com
> 
><><><><><><><><><><><><><><><><><><><><><><>
>Like our page on facebook , Just follow below link
>http://www.facebook.com/discussexcel
>
>-- 
>----------------------------------------------------------------------------------
>
>Some important links for excel users:
>1. Follow us on TWITTER for tips tricks and links : 
>http://twitter.com/exceldailytip
>2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
>3. Excel tutorials at http://www.excel-macros.blogspot.com
>4. Learn VBA Macros at http://www.quickvba.blogspot.com
>5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>
>To post to this group, send email to excel-macros@googlegroups.com
> 
><><><><><><><><><><><><><><><><><><><><><><>
>Like our page on facebook , Just follow below link
>http://www.facebook.com/discussexcel
>
-- 
----------------------------------------------------------------------------------

Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com

To post to this group, send email to excel-macros@googlegroups.com
 
<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to