Re: $$Excel-Macros$$ Check if two files are open; if not, open them

2010-12-15 Thread 0 1
I love it when simple code works so well. Thank you! -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http:

Re: $$Excel-Macros$$ Check if two files are open; if not, open them

2010-12-15 Thread Paul Schreiner
You could simply: On Error Resume Next Workbooks("File1.xls").Close Workbooks("File2.xls").Close On Error Goto 0 Paul - Original Message > From: 0 1 > To: MS EXCEL AND VBA MACROS > Sent: Wed, December 15, 2010 10:36:02 AM > Subject: Re: $$Excel-Macr

Re: $$Excel-Macros$$ Check if two files are open; if not, open them

2010-12-15 Thread 0 1
Using two separate if-then statements did the trick. But now I have a related problem. I'm trying to reverse the code in order to *close* the sheets, if they are open. I figured I could use the same code for the Function WorkbookOpen ..., but a new subroutine for closing them: Public Sub CloseSou

Re: $$Excel-Macros$$ Check if two files are open; if not, open them

2010-12-07 Thread Paul Schreiner
in an if-else-then statement, if the first is false, then Else is evaluated. So, if File1 not open, it opens it. In that case, Else is not evaluated! simply use two separate if-then statements:  If Not WorkbookOpen("File1.xls") Then     Workbooks.Open Filename:="C:\File1.xls"  End If  If Not