D
dan
I have this routine in "TestBook.xls"
Sub check()
' I want to check if "data.csv" is open.
' Why statement "On Error GoTo skip1" works once only?
' I expected Range("L4:L10") = 0 if "data.csv" is not open
' Range("L4:L10") = 1 if "data.csv" is open
' Please help
Dim r As Long
For r = 4 To 10
On Error GoTo skip1
Windows("data.csv").Activate
GoTo skip2
skip1:
Windows("TestBook.xls").Activate
Cells(r, 12) = 0
GoTo skip3
skip2:
Windows("TestBook.xls").Activate
Cells(r, 12) = 1
skip3:
Next r
End Sub
Sub check()
' I want to check if "data.csv" is open.
' Why statement "On Error GoTo skip1" works once only?
' I expected Range("L4:L10") = 0 if "data.csv" is not open
' Range("L4:L10") = 1 if "data.csv" is open
' Please help
Dim r As Long
For r = 4 To 10
On Error GoTo skip1
Windows("data.csv").Activate
GoTo skip2
skip1:
Windows("TestBook.xls").Activate
Cells(r, 12) = 0
GoTo skip3
skip2:
Windows("TestBook.xls").Activate
Cells(r, 12) = 1
skip3:
Next r
End Sub