Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    311

    Unanswered: Copying from one wks to another

    I start with a wks with 1 sheet then add a second sheet and name it look:

    Sheets.Add
    Sheets("Sheet1").Name = "Look"

    then i open my lookup file :

    Workbooks.Open Filename:= _
    "c:\Expense Type Lookup.xls"

    what im trying to do next is Select all the cells in the lookup file
    and paste them to the newly added "Look" sheet in the 1st workbook.

    As the 1st work book name will change each time the macro is run, i cant use the name to do the copy and paste. What i have that doesnt work is :

    Workbooks("Expense Type Lookup.xls").Sheets("Expense Type Lookup").Cells.Copy _
    Sheets("Look")



    Regards

    ~M

  2. #2
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511
    You don't have to use a specific name to reference an Excel workbook; you can store the current workbook name in a variable and use the variable to reference the workbook. Example:

    Dim FirstWBName As String
    FirstWBName = ActiveWorkBook.Name

    From there on, refer to your first workbook as FirstWBName, such as:
    Windows(FirstWBName).Activate

    Good luck!
    Jerry

Posting Permissions

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