View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Allllen Allllen is offline
external usenet poster
 
Posts: 341
Default Macro to change file name in Vlookup formula

try this.

Sub trythis()
i = 1
Do Until IsEmpty(Cells(i, 2))
Cells(i, 2).Formula = Replace(Cells(i, 2).Formula, "DATA2.xls", Cells(i,
1).Value)
i = i + 1
Loop
End Sub
--
Allllen


"msdrolf" wrote:

I have a vlookup formula in column B:
=VLOOKUP($A$10,[DATA2.xls]Sheet1!$A$1:$B$7,2,FALSE)
I have copied this 200 times to sequential rows in column B to pull data
from 200 other spreadsheets.
Is it possible to have a macro which would replace the file name DATA2.xls
with the file name listed in column A of the same row and continue to do so
until it reaches the end of the column.
Thanks