View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Jock Jock is offline
external usenet poster
 
Posts: 440
Default check Wb is open and copy data to it

Guys. Regardless of what I do, when the second Wb is closed, I get run time
errors in:
Set wb = Workbooks(strWorkbook) (Jacob), and
Windows(workbookname & ".xls").Activate (Don)

When Wb is open, both work fine!
Thanks though.
--
Traa Dy Liooar

Jock


"Don Guillett" wrote:

This should activate if open or open if closed

Sub GetWorkbook()
workbookname = "wb2"
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jock" wrote in message
...
Wb1, Sht2 has data in cols A-D. This data is copied to this location by
code
daily when new cases are started on sht1 in the same Wb.
Once a week, I need the data from Sht2 to be copied to WB2, Sht3 by
clicking
a button. Once data copied over to Wb2, Sht 3, the data on Wb1, Sht 2 to
be
deleted.
The problem I am having is checking to see if Wb2 is open - I get the
'subscript out of range' error.
How do I check if a workbook is open (without getting a debug window),
open
it if it is closed and show a message to that effect?
--
Traa Dy Liooar

Jock


.