View Full Version : VBA Code required to see if workbook is opened or not.
Pravina
09-28-2017, 04:45 AM
I want the vba code to check if workbook is opened or not. my workbook name is FER Tracker 15-16. i want to match it with opened with partially "FER Tracker*"
if it is opened then show message box "1st OPEN fer tracker" & terminate procedure.
if found opened . then next statement excutes as it is.
Thanks in advance.
Option Explicit
Sub test()
Dim wb As Workbook
For Each wb In Workbooks
If wb.Name Like "FER Tracker*" Then
MsgBox wb.Name
Exit For
End If
Next
End Sub
マナ
Pravina
09-28-2017, 05:20 AM
Option Explicit
Sub test()
Dim wb As Workbook
For Each wb In Workbooks
If wb.Name Like "FER Tracker*" Then
MsgBox wb.Name
Exit For
End If
Next
End Sub
マナ
Hi Mana,
i want code like below.
sub test ()
dim wb as workbook
for each wb in workbook
if not wb.name like "FER Tracker*" then
msgbox "FER Tracker is not opened"
exit sub 'to teminate the whole procedure.
end if
next wb
end sub
>i want code like below.
I can't understand what is your problem.
Paul_Hossler
09-28-2017, 06:11 AM
Hi Mana,
i want code like below.
sub test ()
dim wb as workbook
for each wb in workbook
if not wb.name like "FER Tracker*" then
msgbox "FER Tracker is not opened"
exit sub 'to teminate the whole procedure.
end if
next wb
end sub
Sub test()
Dim bWorkbookOpen As Boolean
Dim wb As Workbook
bWorkbookOpen = False
For Each wb In applicatiom.Workbooks
If wb.Name Like "FER Tracker*" Then bWorkbookOpen = True
Next
If Not bWorkbookOpen Then
MsgBox "1st OPEN fer tracker"
Exit Sub
End If
' continue
End Sub
Pravina
09-28-2017, 11:40 PM
Sub test()
Dim bWorkbookOpen As Boolean
Dim wb As Workbook
bWorkbookOpen = False
For Each wb In applicatiom.Workbooks
If wb.Name Like "FER Tracker*" Then bWorkbookOpen = True
Next
If Not bWorkbookOpen Then
MsgBox "1st OPEN fer tracker"
Exit Sub
End If
' continue
End Sub
Thank you very much Paul for your support.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.