I run update macro loop to process about 50 spreadsheets, but sheets could
be used (open) by somebody. I need to skip processing of the sheet if it is
open. Something like this:
For R = 1 to 50
If FileR is open then goto Skip '<======This is what I need
Open_sheet
Update_it
Save_and_Close_it
Skip:
Next R
Thanks for your help
Jan
Jim Cone - 22 Mar 2006 04:41 GMT
Jan,
Something like the following...
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
'----------------------
Sub OpenClosedFilesOnly()
Dim R
For R = 1 To 50
If Not IsItOpen(FileR) Then
Open_sheet
Update_it
Save_and_Close_it
End If
Skip:
Next R
End Sub
' Returns True or False.
'------------------
Function IsItOpen(ByRef BookName As String) As Boolean
Dim WB As Workbook
On Error Resume Next
Set WB = Workbooks(BookName)
IsItOpen = (Err.Number = 0)
Set WB = Nothing
End Function
'------------------------------------------------
"Jan Nademlejnsky" <jannade@shaw.ca> wrote in message
I run update macro loop to process about 50 spreadsheets, but sheets could
be used (open) by somebody. I need to skip processing of the sheet if it is
open. Something like this:
For R = 1 to 50
If FileR is open then goto Skip '<======This is what I need
Open_sheet
Update_it
Save_and_Close_it
Skip:
Next R
Thanks for your help
Jan