+ Reply to Thread
Results 1 to 2 of 2

Workbook focus when opened by another workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    10-27-2009
    Location
    Georgia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Workbook focus when opened by another workbook

    I am trying to copy data from one workbook (Sheet1) to another Workbook (sheet specified by cell value) in this particular way...
    I have a macro that opens a *.dat file in workbook1. In Workbook(1) I have a cell (Value is "May") that I want to use as a means to open worksheet 'May" in workbook2 and then copy Workbook1 (sheet1) to workbook2 (Sheet "May") I can successfully open Workbook2 but when I try to "find" Sheet (May) in WB2 by using sheet.count in a For...Next loop It counts in WB1 sheet(1). Any suggestions??

    Oh, and before someone asks the obvious... I have to do it this way because I'm getting data from a device that has a hardcoded excel file to get the *.dat data to excel and this is workbook1.

    Any ideas would be appreciated.

    Robert

  2. #2
    Forum Contributor
    Join Date
    09-21-2009
    Location
    Belgium - Mechelen
    MS-Off Ver
    Office 365 - version 2310
    Posts
    278

    Re: Workbook focus when opened by another workbook

    hi ,

    If you're familiar with VBA you could work with variables to define your workbooks

    
    Dim MyWb1 ' workbook 1
    Dim myWb2 ' workbook 2
    
    
    'asign the actual workbook to MyWb1
    
    Mywb1 = Activeworkbook.Name
    
    'Then if you open workbook2 asign Mywb2 to it
    
    MyWb2 = Activeworkbook.Name
    
    
    'To set the workbook active 
    
    MyWb1.Activate
    
    'or
    
    MyWb2.Activate
    and then you can get the workbook you need to be active .

    Hope this helps.

+ 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