ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Retrieving Cell Data From Variable Files (https://www.excelbanter.com/excel-worksheet-functions/140212-retrieving-cell-data-variable-files.html)

DJ Pomeroy

Retrieving Cell Data From Variable Files
 
Okay, this is what I'm trying to do.

I would like to create a log that would track changes from other files. This
log file would know the file names based on other information in the log. I
would like to do it this way so I won't have to change every line of the
log. Is there a way to place a type of "=d2" formula when looking into
another file?

For example, For Cell A2, I want it to get the file from:

C:\Files\Subfolder\FileName.xls

"Subfolder" will be whatever is listed in cell D2
"File Name" will actually be what is listed in cell E2 + cell F2
And then inside that file, I'll want it to come back with Cell A1 (or
whatever).

Is this possible?


bj

Retrieving Cell Data From Variable Files
 
try
=indirect("[C\Files"&d2&"\"&E2&F2&"]"&"Sheet1!A1")

"DJ Pomeroy" wrote:

Okay, this is what I'm trying to do.

I would like to create a log that would track changes from other files. This
log file would know the file names based on other information in the log. I
would like to do it this way so I won't have to change every line of the
log. Is there a way to place a type of "=d2" formula when looking into
another file?

For example, For Cell A2, I want it to get the file from:

C:\Files\Subfolder\FileName.xls

"Subfolder" will be whatever is listed in cell D2
"File Name" will actually be what is listed in cell E2 + cell F2
And then inside that file, I'll want it to come back with Cell A1 (or
whatever).

Is this possible?



Bernie Deitrick

Retrieving Cell Data From Variable Files
 
DJ,

Note that the INDIRECT method won't work on closed files. But one way that will work is to create
the referencing formulas with formulas, and then using a macro to convert to actual formulas. For
example, to pull cell D2:


In cell A2, use the formula

="='C:\Files\" & D2 & "\[" & E2 & "]" &F2 & "'!D2"

In cell D2, put the foldername.

In cell E2, put the filename, including the .xls

In cell F2, put the sheet name

Then copy those cells down as far as you need.

Then select the cells in column F, and run this macro:


Sub ConvStringToFormula()
Dim myCell As Range
For Each myCell In Selection
myCell.Formula = myCell.Text
Next
End Sub

HTH,
Bernie
MS Excel MVP



"DJ Pomeroy" wrote in message
...
Okay, this is what I'm trying to do.

I would like to create a log that would track changes from other files. This log file would know
the file names based on other information in the log. I would like to do it this way so I won't
have to change every line of the log. Is there a way to place a type of "=d2" formula when looking
into another file?

For example, For Cell A2, I want it to get the file from:

C:\Files\Subfolder\FileName.xls

"Subfolder" will be whatever is listed in cell D2
"File Name" will actually be what is listed in cell E2 + cell F2
And then inside that file, I'll want it to come back with Cell A1 (or whatever).

Is this possible?




bj

Retrieving Cell Data From Variable Files
 
Smooth, I like it
"Bernie Deitrick" wrote:

DJ,

Note that the INDIRECT method won't work on closed files. But one way that will work is to create
the referencing formulas with formulas, and then using a macro to convert to actual formulas. For
example, to pull cell D2:


In cell A2, use the formula

="='C:\Files\" & D2 & "\[" & E2 & "]" &F2 & "'!D2"

In cell D2, put the foldername.

In cell E2, put the filename, including the .xls

In cell F2, put the sheet name

Then copy those cells down as far as you need.

Then select the cells in column F, and run this macro:


Sub ConvStringToFormula()
Dim myCell As Range
For Each myCell In Selection
myCell.Formula = myCell.Text
Next
End Sub

HTH,
Bernie
MS Excel MVP



"DJ Pomeroy" wrote in message
...
Okay, this is what I'm trying to do.

I would like to create a log that would track changes from other files. This log file would know
the file names based on other information in the log. I would like to do it this way so I won't
have to change every line of the log. Is there a way to place a type of "=d2" formula when looking
into another file?

For example, For Cell A2, I want it to get the file from:

C:\Files\Subfolder\FileName.xls

"Subfolder" will be whatever is listed in cell D2
"File Name" will actually be what is listed in cell E2 + cell F2
And then inside that file, I'll want it to come back with Cell A1 (or whatever).

Is this possible?






All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com