Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to unhide worksheet in multiple files within the same folder

Status
Not open for further replies.

sazi22

Technical User
Oct 7, 2004
43
0
0
US
I have a bunch of files that I need to unhide a worksheet in. The sheet has the same name in all files and all files are located in one folder. How would I do this?

Thanks.
 
Have a look at the Dir VBA function, the Open method of the Workbooks collection, the Visible property of the Worksheet object, ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 


Hi,

Check out the FileSystemObject. You can look thru all the workbooks in a folder.

Is the Sheet Name identical in each workbook?

Skip,
[sub]
[glasses] [red]Be Advised![/red]
The band of elderly oriental musicians, known as Ground Cover, is, in reality...
Asian Jasmine![tongue][/sub]
 
Thanks! Yes... the sheet name is identical.
 
If it is Excel i would make a .vbs file along the lines of: -
Code:
Dim Shell, Excel
Dim myFolder,myItems,numitems,mySheet
Set Excel = CreateObject("excel.Application")
Set Shell = CreateObject("Shell.Application")
dDir = "C:\myDir"
mySheet = "sheet 1"
set myFolder = shell.NameSpace(sDir)
If (Not myFolder Is Nothing) Then
    set myItems = myFolder.Items
    If (not myItems Is Nothing) Then
        numitems = myItems.Count
        If(numitems > 0) Then
        For n = 0 To numitems
            myFilePath = myItems.Item(n).Path
            Excel.Workbooks.Open(myFilePath)
            Excel.Sheets(mySheet).Select
            Excel.ActiveWindow.SelectedSheets.Visible = True
            Excel.ActiveWorkbook.Save
            Excel.Application.Quit
        Next
    End If
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top