Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro to change file name in Vlookup formula

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default Macro to change file name in Vlookup formula

Maybe you don't need a macro. Say that the file names begin in row 1 of
column A. Then in B1 enter:

=VLOOKUP($A$10,INDIRECT(CONCATENATE("[",A1,"]Sheet1!$A$1:$B$7")),2,FALSE)

And copy it down 200 times.

HTH

-John Coleman

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


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

neat answer
--
Allllen


"John Coleman" wrote:

Maybe you don't need a macro. Say that the file names begin in row 1 of
column A. Then in B1 enter:

=VLOOKUP($A$10,INDIRECT(CONCATENATE("[",A1,"]Sheet1!$A$1:$B$7")),2,FALSE)

And copy it down 200 times.

HTH

-John Coleman

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro to change file name in Vlookup formula

Thanks for your suggestion. Unfortunatley it has only limited application.
You need to keep all the source workbooks open. The INDIRECT connection is
broken when you close the source files. The VLOOKUP link remains even after
the files are closed. That is why I was hoping there was an easy way to
change the file name in the VLOOKUP formula. Thanks for trying.

"John Coleman" wrote:

Maybe you don't need a macro. Say that the file names begin in row 1 of
column A. Then in B1 enter:

=VLOOKUP($A$10,INDIRECT(CONCATENATE("[",A1,"]Sheet1!$A$1:$B$7")),2,FALSE)

And copy it down 200 times.

HTH

-John Coleman

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default Macro to change file name in Vlookup formula

Alllen's VBA approach should work with little problem in that case. I
find it disappointing that
Excel's worksheet reference functions are too weak to handle this
directly. I was hoping that some work around was possible.

-John Coleman

msdrolf wrote:
Thanks for your suggestion. Unfortunatley it has only limited application.
You need to keep all the source workbooks open. The INDIRECT connection is
broken when you close the source files. The VLOOKUP link remains even after
the files are closed. That is why I was hoping there was an easy way to
change the file name in the VLOOKUP formula. Thanks for trying.

"John Coleman" wrote:

Maybe you don't need a macro. Say that the file names begin in row 1 of
column A. Then in B1 enter:

=VLOOKUP($A$10,INDIRECT(CONCATENATE("[",A1,"]Sheet1!$A$1:$B$7")),2,FALSE)

And copy it down 200 times.

HTH

-John Coleman

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






  #6   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change a Table_Array size in a VLookup formula? Nickman Excel Discussion (Misc queries) 2 February 19th 07 07:20 PM
Change Code in Macro to specify file/folder to look in. Dtown Dawg Excel Programming 1 July 14th 06 06:34 PM
Change a Macro commands reference to file locations Tomkat743 Excel Programming 0 April 20th 06 05:10 PM
macro code to change file-opening password arunjoshi[_18_] Excel Programming 1 June 16th 05 08:49 AM
mass change table_array Name in VLOOKUP formula GabbyU Excel Worksheet Functions 3 January 31st 05 09:31 AM


All times are GMT +1. The time now is 06:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"