View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ardus Petus Ardus Petus is offline
external usenet poster
 
Posts: 718
Default External Reference - Filename Change


var = "1111"
Range("L2").Value = Range("'["oef-" & var & ".xls]Sheet1'!C12").Value

HTH
--
AP

"bg18461" a écrit
dans le message de news:
...

I am trying to create VB code that takes data from one workbook and adds
info to a master workbook (database).

The filenames will all have the same prefix followed by a series of
numbers.

Here is the code that I am using to grab the data from one workbook and
insert it into the database.

Range("L2").Value = Range("'[oef.xls]Sheet1'!C12").Value

This code assumes that the name of the file I am inserting will always
be oef.xls, however I will be taking data from files called
oef-1111.xls
oef-2222.xls
oef-3333.xls, etc...

I would like the code to be able to pull from these files without me
having to rename the sheets from oef-1111.xls to oef.xls.

Thanks for your input.


--
bg18461
------------------------------------------------------------------------
bg18461's Profile:
http://www.excelforum.com/member.php...fo&userid=8877
View this thread: http://www.excelforum.com/showthread...hreadid=549910