Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting path and filename from a formula with links

Status
Not open for further replies.

Gavona

Technical User
Aug 27, 2002
1,771
GB
I am selecting up to 20 cells containing formulae.
I want to identify if a formula involves a link to another workbook. If it does then I want to extract the filename and the path so that I can:
(i) test it exists
(ii)open it
before I copy the formulae to more cells
Thread707-1215569 tells a bit more of the context.

In Excel if the formula is in cell C2 then the filename can be extracted with:
=MID(C2,FIND("[",$C2)+1,FIND("]",$C2)-FIND("[",$C2)-1)

and the path with
=MID(C2,FIND("\",$C2)-2,FIND("[",$C2)-FIND("\",$C2)+2)

I guess the final solution will need to test for another link within the same cell to a different worksheet.

So I have the formulae in Excel but how do I do the equivalent in VBA? C2 would be replaced by a variable MyFormula
I guess I would put the results in
MyPath
MyFilename

Thanks,


Gavin
 
Have a look at the InStr function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top