View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default VBA Code Activates a workbook only sometimes

You can't activate a sheet in a workbook which is not active. So you can go
either way

Workbooks("ACT-Reports.xls").Activate
Workbooks("ACT-Reports.xls").Worksheets("Reports").Activate

or

Application.Goto Workbooks("ACT-Reports.xls") _
.Worksheets("Reports").Range("A1")


But you don't need to loop to do it.
--
Regards,
Tom Ogilvy


"GusEvans" wrote in message
...
Coded a relatively complex program. When I execute the following -
Workbooks("ACT-Reports.xls").Worksheets("Reports").Activate
It was working for a few weeks then the only way to do the same thing

became -
For Each bkTempBooKxx In Workbooks
If bkTempBooKxx.Name = "ACT-Reports.xls" Then
bkTempBooKxx.Activate
For Each shtWork In Worksheets
If shtWork.Name = "Reports" Then
shtWork.Activate
Exit For
End If
Next
Exit For
End If
Next
Set bkACTRpt = ActiveWorkbook
Don't understand????
--
Thanks for any suggestions,
Gus Evans