Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a program where I loop throught the worksheets in a folder and copy
the information from a worksheet called "Print_Recap". There are a few workbooks in the folder that don't have this sheet and I simply want to skip them and go on to the next workbook. The code i have gives me an error message whenever it gets to a workbook without the "Print_Recap" worksheet. here's what I tried using but it doesn't work. I get error 9 subscript out of range Do While FNames < "" Set mybook = Workbooks.Open(FNames) Dim SheetExists As Boolean SheetExists = False SheetExists = CBool(Len(mybook.Sheets("Print_Recap").Name)) If SheetExists Then 'some code to run goes here Else SheetExists = False End If Loop -- Billy Rogers Dallas,TX Currently Using SQL Server 2000, Office 2000 and Office 2003 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this
Sub findme() Dim wsSheet As Worksheet On Error Resume Next Set wsSheet = Sheets("Print_Recap") On Error GoTo 0 If Not wsSheet Is Nothing Then MsgBox "I'm Here" Else MsgBox "It's all gone dark" End If End Sub Mike "BillyRogers" wrote: I have a program where I loop throught the worksheets in a folder and copy the information from a worksheet called "Print_Recap". There are a few workbooks in the folder that don't have this sheet and I simply want to skip them and go on to the next workbook. The code i have gives me an error message whenever it gets to a workbook without the "Print_Recap" worksheet. here's what I tried using but it doesn't work. I get error 9 subscript out of range Do While FNames < "" Set mybook = Workbooks.Open(FNames) Dim SheetExists As Boolean SheetExists = False SheetExists = CBool(Len(mybook.Sheets("Print_Recap").Name)) If SheetExists Then 'some code to run goes here Else SheetExists = False End If Loop -- Billy Rogers Dallas,TX Currently Using SQL Server 2000, Office 2000 and Office 2003 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Test if file exists | Excel Discussion (Misc queries) | |||
Test if sheet exists create if not | Excel Programming | |||
How to test if a DLL (library) exists | Excel Programming | |||
Test if Sheet Exists - Tom Ogilvy | Excel Programming | |||
Test for Worksheet Exists | Excel Programming |