How to code macro with condition?
Use a function as below...
Sub Macro()
If IsWorkbookOpen("Book1") = False Then
'Place your code below
End If
End Sub
Function IsWorkbookOpen(strWorkbook) As Boolean
Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks(strWorkbook)
If Not wb Is Nothing Then IsWorkbookOpen = True
End Function
--
Jacob (MVP - Excel)
"Eric" wrote:
If specific file is currently opened, then not processing following coding,
else process them.
Does anyone have any suggestions on how to code it in macro?
Thanks in advance for any suggestions
Eric
Sub RunOrNot
'Is specific file opened? if not, then process following coding
Coding
'End If
End Sub
|