PC Review


Reply
Thread Tools Rate Thread

browse between worksheets ?

 
 
=?Utf-8?B?ZXhjZWwtdHI=?=
Guest
Posts: n/a
 
      9th Mar 2007
Hi,

assume you have 20 workbooks and 20 worksheet in each workbook.totally 400
worksheets.if 20 workbooks are in one folder, when below code is run, all
worksheet names ( 400 ) are written in a page.but if there is a folder in a
folder, below code cannot see the workbooks in the folder.

for example;assume you have excel files and one folder ( named sample ) in
adress C:\Documents and Settings.
below code cannot get worksheet names from the folder, how can we change the
code to browse all excel files whether they are in a folder or not ?

any expert ?



Sub GetAllWorksheetNames()
Dim i As Integer
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Dim wSheet As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False

On Error Resume Next

Set wbCodeBook = ThisWorkbook

With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings" 'amend to suit
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Set wbResults = Workbooks.Open(.FoundFiles(i))

wbCodeBook.Sheets(1).Range _
("A65536").End(xlUp)(2, 1) = UCase(wbResults.Name)
For Each wSheet In wbResults.Worksheets
wbCodeBook.Sheets(1).Range _
("A65536").End(xlUp)(2, 1) = wSheet.Name
Next wSheet
wbResults.Close SaveChanges:=False
Next i
End If
End With

On Error GoTo 0
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub



--
SAHRAYICEDIT-ISTANBUL
 
Reply With Quote
 
 
 
 
NOPIK
Guest
Posts: n/a
 
      9th Mar 2007

> below code cannot get worksheet names from the folder, how can we change the
> code to browse all excel files whether they are in a folder or not ?


> With Application.FileSearch
> .NewSearch
> .LookIn = "C:\Documents and Settings" 'amend to suit
> .FileType = msoFileTypeExcelWorkbooks

..SearchSubFolders = True ?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to heirarchically group worksheets, or browse them differently? andrew.fabbro@gmail.com Microsoft Excel Misc 2 18th Jul 2006 10:00 PM
can't browse some common websites, will browse others =?Utf-8?B?ZnV0dXJlZmlsZQ==?= Windows XP Internet Explorer 0 21st Oct 2004 06:09 AM
Re: Can't browse network in XP but others can browse this computer Ted Turner Windows XP Help 1 19th May 2004 06:16 PM
Cant Browse - internet connection established but cant browse =?Utf-8?B?U2hhbmV5X3Q=?= Windows XP Internet Explorer 1 14th May 2004 01:53 PM
DSL Connection stays, but cannot browse. Reconned and I can browse again... Marco Napoli Windows XP General 3 15th Aug 2003 10:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:08 PM.