|
-
May 28th, 2012, 02:37 PM
#1
Thread Starter
New Member
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???
-
Jun 2nd, 2012, 04:22 AM
#2
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|