+ Reply to Thread
Results 1 to 4 of 4

VBA Code Activates a workbook only sometimes

Hybrid View

Guest VBA Code Activates a workbook... 03-20-2006, 09:20 PM
Guest Re: VBA Code Activates a... 03-20-2006, 10:45 PM
Guest Re: VBA Code Activates a... 03-21-2006, 12:15 AM
Guest RE: VBA Code Activates a... 03-21-2006, 12:30 AM
  1. #1
    Tom Ogilvy
    Guest

    Re: 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" <GusEvans@discussions.microsoft.com> wrote in message
    news:A7500F89-0857-4CBC-9D59-5A16FDB5D8DE@microsoft.com...
    > 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. #2
    GusEvans
    Guest

    Re: 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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1