Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default VBA Code Activates a workbook only sometimes

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default VBA Code Activates a workbook only sometimes


--
Gus Evans


"Tom Ogilvy" wrote:

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")

The second command -
Workbooks("ACT-Reports.xls").Worksheets("Reports").Activate
and the -
Application.Goto Workbooks("ACT-Reports.xls") _
.Worksheets("Reports").Range("A1")
Both caused a 32809 error!

I can't figure it out either!

Gus Evans
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default VBA Code Activates a workbook only sometimes

Another comment -

I opened ACT-Reports.xls, then opened Sheet1.xls. went back to
ACT-Reports.xls, put the code in a module, then started stepping thru the
code, made Sheet1.xls the active workbook, and continued stepping thru the
code - got the 32809 error.

Gus Evans
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selection from dropdown list activates hyperlink jlind50 Excel Discussion (Misc queries) 1 June 5th 07 03:38 AM
Special Menu activates Web Toolbar BEEJAY Excel Discussion (Misc queries) 0 July 4th 06 01:40 PM
Rectangle that activates a macro No Name Excel Programming 3 January 7th 05 06:49 PM
VB activates unwanted function Urban Excel Programming 3 July 6th 04 06:59 PM
Solver activates other worksheets - why? Ken Dahlberg Excel Programming 1 September 12th 03 06:05 PM


All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"