+ Reply to Thread
Results 1 to 2 of 2

Activate workbook without using file name

Hybrid View

  1. #1
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58

    Activate workbook without using file name

    Good morning,

    I have another silly question. In a macro, is it possible to open a workbook without using the path name?

    I get one sheet with data. This sheet will have a different name every day. I'll call this one NewSheet. From this I wish to transfer data to a fixed sheet, for which I do have a file path (FixedSheet). Moving from NewSheet to FixedSheet is easy, beacuse I can use the path, but how can I go back to the other sheet? There are no other workbooks open.

    I have worked out an alternative, which is to save the NewSheet as TempSheet in a fixed location, replace the previous one and use that file path, but I am wondering if there is an actual command to do this.

    Does anybody know?

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You don't need to switch workbooks. Your code would be in the master workbook, so you open the new book and leave it active, then run this macro (amend it to suit) from master workbook by using the Tools menu >-Macros
    Option Explicit
    Sub grabData()
        Dim SourceWb As Workbook
    
        Set SourceWb = ActiveWorkbook
    
        SourceWb.UsedRange.Copy ThisWorkbook.Sheets.Cells(1, 1)
        SourceWb.Close False
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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