Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
beginnerExceluser
 
Posts: n/a
Default Linking cells to files in a folder

Hello,
I'd like to link cells in a column to files in a folder. The cell value is
the file name within the folder.

Is there an easy way to do this without linking one cell at a time?

Thank you.
  #2   Report Post  
Mel Arquiza
 
Posts: n/a
Default

Try to cut and paste this macro code to a new excel file and run.

Sub AutoHyperlinkFileNametoExcel()
Dim fnam As Variant

' fnam is an array of files returned from GetOpenFileName
' note that fnam is of type boolean if no array is returned.
' That is, if the user clicks
' on cancel in the file open dialog box, fnam is set to FALSE

Dim b As Integer 'counter for filname array
Dim b1 As Integer 'counter for finding \ in filename
Dim Cell As Range
Dim x As Integer
' first open a blank sheet and go to top left ActiveWorkbook.Worksheets.Add

fnam = Application.GetOpenFilename("all files (*.*), *.*", 1, _
"Select Files to Fill Range", "Get Data", True)

If TypeName(fnam) = "Boolean" And Not (IsArray(fnam)) Then Exit
Sub 'if user hits cancel, then end

For b = 1 To UBound(fnam)

' print out the filename (with path) into first column of new
sheet
ActiveSheet.Cells(b, 1) = fnam(b)
b1 = Len(fnam(b))

' add any other columns to s/s here
' this code makes the drawing name from the filename
' by stripping off the directory name and the extension

Do While Mid(fnam(b), b1, 1) < "\"
b1 = b1 - 1
Loop
Next
'resize the columns

ActiveSheet.Range("a:zz").Columns.AutoFit
x = ActiveSheet.UsedRange.Rows.Count
Range("B1").Select
ActiveCell.FormulaR1C1 = "=HYPERLINK(RC[-1])"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B" & x), Type:=xlFillDefault
End Sub



"beginnerExceluser" wrote:

Hello,
I'd like to link cells in a column to files in a folder. The cell value is
the file name within the folder.

Is there an easy way to do this without linking one cell at a time?

Thank you.

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
linking whole rows of cells fxcel Excel Worksheet Functions 1 July 2nd 05 12:16 PM
Export html page to Excel - support files folder Export html page to Excel - support file Excel Discussion (Misc queries) 1 June 24th 05 12:36 PM
Linking Formats Across Cells RB Excel Discussion (Misc queries) 1 June 16th 05 10:20 PM
Macro to copy range from Excel files in folder nc Excel Discussion (Misc queries) 1 June 15th 05 11:11 AM
Copy files from spreadsheet into folder Intotao Excel Discussion (Misc queries) 3 January 27th 05 11:38 PM


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

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"