Workbook A(Sheet 1) and Workbook B(Sheet 2) are opened or not
Hi all,please help...
I want to write a VB-Excel macro , which will prompt a messgae box "Both W.B opened" if this macro finds Workbook A(Sheet 1) and Workbook B(Sheet 2) opened else msgbox "W.B NOT opened"
Can anyone write it for me???
Re: Workbook A(Sheet 1) and Workbook B(Sheet 2) are opened or not
vb Code:
for wb = 1 to workbooks.count
if wb.name = "workbookA.xls" then
for each sh in wb.sheets
if sh.name = "Sheet1" then a = true: exit for
next
elseif wb.name = "workbookB.xls" then
for each sh in wb.sheets
if sh.name = "Sheet2" then b = true: exit for
next
end if
next
if a and b then
msgbox "both open"
else
msgbox "both not open
end if
names of workbooks and sheets need to be exact and case sensitve