Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 460
Default using cell value to open file

It's been several years since I've been on this site, boy have things
changed. I posted a few days ago and lost it somewhere, so I'm going to try
again.

I have a sheet listing job numbers, addresses, names, etc. I have a budget
for each job saved as separate files with the job number in the file name. I
would like to be able to click on any job number in my list, and have it open
the corresponding budget file. Any ideas.

Thanks for the help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default using cell value to open file

You could make them hyperlinks...

Cliff Edwards

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default using cell value to open file

Try this code. Change folder as required

Sub OpenJobFile()

Folder = "C:\temp"

JobNumber = ActiveCell.Value

FName = Dir(Folder & "\*" & JobNumber & "*.xls")

If FName = "" Then
MsgBox ("Cannot find file : " & Folder & "\*" & JobNumber & "*.xls")
Else
Workbooks.Open Filename:=Folder & "\" & FName
End If

End Sub


"ward376" wrote:

You could make them hyperlinks...

Cliff Edwards


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 460
Default using cell value to open file

That looks great, I'll try it. Here's another issue.

The job numbers are grouped by subdivsion, so if I have job numbers in
SubDivRange1 or SubDivRange2, etc., how do I find the range name so I can
include that name in the file path with the job number?

"Joel" wrote:

Try this code. Change folder as required

Sub OpenJobFile()

Folder = "C:\temp"

JobNumber = ActiveCell.Value

FName = Dir(Folder & "\*" & JobNumber & "*.xls")

If FName = "" Then
MsgBox ("Cannot find file : " & Folder & "\*" & JobNumber & "*.xls")
Else
Workbooks.Open Filename:=Folder & "\" & FName
End If

End Sub


"ward376" wrote:

You could make them hyperlinks...

Cliff Edwards


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default using cell value to open file

Not sure if this is the best method, but it works. Use intersect to
determine if cell is in the range of each name in the workbook.

RangeName = ""
For Each nm In ActiveWorkbook.Names
NameAddr = nm.RefersToRange.Address
If Not Intersect(Range(NameAddr), ActiveCell) Is Nothing Then
RangeName = nm.Name
Exit For
End If
Next nm
If RangeName < "" Then
'enter your code here
End If

"Doug" wrote:

That looks great, I'll try it. Here's another issue.

The job numbers are grouped by subdivsion, so if I have job numbers in
SubDivRange1 or SubDivRange2, etc., how do I find the range name so I can
include that name in the file path with the job number?

"Joel" wrote:

Try this code. Change folder as required

Sub OpenJobFile()

Folder = "C:\temp"

JobNumber = ActiveCell.Value

FName = Dir(Folder & "\*" & JobNumber & "*.xls")

If FName = "" Then
MsgBox ("Cannot find file : " & Folder & "\*" & JobNumber & "*.xls")
Else
Workbooks.Open Filename:=Folder & "\" & FName
End If

End Sub


"ward376" wrote:

You could make them hyperlinks...

Cliff Edwards


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
open file by inputting file name in cell? Roger Abbot Excel Discussion (Misc queries) 1 September 15th 07 02:38 PM
How do I open a file from a named cell? Cumberland Excel Programming 3 May 23rd 06 09:11 AM
open image file from cell value el_peacock Excel Programming 7 May 2nd 06 05:34 PM
Open file with file name from cell Thore Excel Programming 1 August 24th 04 10:20 AM
Open file from Cell Brad Excel Programming 2 April 13th 04 04:56 PM


All times are GMT +1. The time now is 11:36 AM.

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

About Us

"It's about Microsoft Excel"