PC Review


Reply
Thread Tools Rate Thread

Anyway to replace absolute file path in formula with relative or use Info(directory)?

 
 
RocketDude
Guest
Posts: n/a
 
      18th Aug 2005
Hi,

I have a workbook that looks summarizes data that is in multiple (60) other
workbooks, and want to know if there is someway to craft my look such that
the folder structure doesn't manner --I want to be able to share this
workbook with a teammate and not have the lookups fail, so long as the
folder structure at the file level is the same.

Here is the setup:

Summary file
C:\xxx\xxx\xxx\summary file.xls
Data files
C:\xxx\xxx\xxx\data files\folder1\data.xls
C:\xxx\xxx\xxx\data files\folder2\data.xls
....
C:\xxx\xxx\xxx\data files\folder60\data.xls

I want to somehow craft my lookup -- right now my lookup is
='C:\xxx\xxx\xxx\data files\folder1\[data.xls]worksheet'!$P3 -- so that the
C:\xxx\xxx\xxx\ is added automatically. I tried using INFO("directory") to
get the path, but I could figure out how to use that in the formula.

TIA

--
Matthew


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      18th Aug 2005
Maybe you could do something like this...

Instead of storing the link as a formula:
='C:\xxx\xxx\xxx\data files\folder1\[data.xls]worksheet'!$P3

Store it as text
$$$$$='%%%%\data files\folder1\[data.xls]worksheet'!$P3

Then you could have an auto_open macro that does a couple of mass changes:
edit|replace
what: %%%%
with: thisworkbook.path
replace all

And then the same kind of thing to change the strings to formulas:
edit|replace
what: $$$$$=
with: =
replace all

Something like this in code:

Option Explicit
Sub auto_open()

With Worksheets("sheet1")
.Cells.Replace what:="%%%%", replacement:=ThisWorkbook.Path, _
lookat:=xlPart, MatchCase:=False, searchorder:=xlByRows
.Cells.Replace what:="$$$$$=", replacement:="=", lookat:=xlPart, _
MatchCase:=False, searchorder:=xlByRows
End With

End Sub

Make sure those folders/files exist--it could mean trouble if the workbooks
couldn't be found--each formula would cause a dialog to popup looking for it.

RocketDude wrote:
>
> Hi,
>
> I have a workbook that looks summarizes data that is in multiple (60) other
> workbooks, and want to know if there is someway to craft my look such that
> the folder structure doesn't manner --I want to be able to share this
> workbook with a teammate and not have the lookups fail, so long as the
> folder structure at the file level is the same.
>
> Here is the setup:
>
> Summary file
> C:\xxx\xxx\xxx\summary file.xls
> Data files
> C:\xxx\xxx\xxx\data files\folder1\data.xls
> C:\xxx\xxx\xxx\data files\folder2\data.xls
> ...
> C:\xxx\xxx\xxx\data files\folder60\data.xls
>
> I want to somehow craft my lookup -- right now my lookup is
> ='C:\xxx\xxx\xxx\data files\folder1\[data.xls]worksheet'!$P3 -- so that the
> C:\xxx\xxx\xxx\ is added automatically. I tried using INFO("directory") to
> get the path, but I could figure out how to use that in the formula.
>
> TIA
>
> --
> Matthew


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script w/relative path that sends absolute path to a folder to theclipboard? StargateFanNotAtHome@mailinator.com Microsoft Outlook VBA Programming 3 24th Mar 2009 01:32 PM
Absolute verses Relative file path in SQL =?Utf-8?B?Uml2ZXJHdWxseQ==?= Microsoft Excel Programming 4 21st Oct 2007 07:59 PM
Changing the default file path from absolute to relative =?Utf-8?B?VER1bms=?= Microsoft Frontpage 4 16th Dec 2005 02:15 AM
why relative hint path but absolute reference path gerry Microsoft Dot NET Framework 1 23rd Sep 2004 09:44 AM
There are any Path or Directory function to convert an absolute pathto a relative path? Ffelagund Microsoft VC .NET 2 8th Mar 2004 07:26 PM


Features
 

Advertising
 

Newsgroups
 


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