In a function I'm writing, I need to find the number of open workbooks, but I want to exclude those that are hidden. Please help!<br>
<br>
Thanks<br>
Barry
Hi Barryg<br>
<br>
As you probably know there is no method to count visible workbooks. However, try this routine and I hope it works<br>
<br>
<br>
Sub VisibleWorkbooks()<br>
'Count the number of Open Workbooks<br>
vopenworkbooks = Application.Windows.Count<br>
vvisible = 0<br>
'Loop to check is the workbook hidden<br>
For counter = 1 To vopenworkbooks<br>
If Windows(counter).Visible = True Then vvisible = vvisible + 1<br>
Next<br>
MsgBox ("the Number of Workbooks open and not hidden is " & vvisible)<br>
<br>
End Sub<br>
<br>
<br>
Let me know how you get on!!<br>
<br>
Regards<br>
Monica
Thanks, Monica. It worked well. I was stuck because visible wasn't a valid property of the workbooks collection and I didn't know about the Windows collection. I'm very new to VBA in Excel so it's taking a while to learn to collection, properties, methods, etc.<br>
<br>
Thanks again,<br>
Barry
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.