Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default New Sheets for hyperlinked files

I have a macro that will open a list of hyperlinked files, now i want
to compile information out of those files into a master file. The file
names all start with the job number (e.g. Job3*.xls), and I'd like to
make a new sheet for each job number. I'm pretty new to this, so I
don't even know if this is possible. Once the sheets are created, I've
got the data pulling macro working, but right now I have to create the
new sheets manually first. Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default New Sheets for hyperlinked files

here's a demo. The 'demo' procedure is the entrypoint. all it does is to
allow the user to point at a file and then it passes that filename tothe grab
routine. All your code would need to do is make the same call...

Option Explicit
' this grabs a workbook and copies the data in sheet1 to
' the active workbook
Sub demo()
Dim fn As String
fn = Application.GetOpenFilename()
If UCase(fn) < "FALSE" Then GrabData (fn)
End Sub
Sub GrabData(fn As String)
Dim filename As String
Dim ws As Worksheet
Dim wb As Workbook
Dim source As Range
Set ws = Worksheets.Add()
filename = GetFileName(fn)
ws.Name = filename
Set wb = Workbooks.Open(fn)
Set source = wb.Worksheets(1).UsedRange

With ws
.Range("A1").Resize(source.Rows.Count, source.Columns.Count).Value =
source.Value
End With
wb.Close False


End Sub
Function GetFileName(fn As String) As String
Dim pos As Long
pos = InStrRev(fn, "\")
If pos 0 Then
GetFileName = Mid(fn, pos + 1)
Else
GetFileName = fn
End If
'strip off the extension
GetFileName = Left(GetFileName, Len(GetFileName) - 4)
End Function


"Craig" wrote:

I have a macro that will open a list of hyperlinked files, now i want
to compile information out of those files into a master file. The file
names all start with the job number (e.g. Job3*.xls), and I'd like to
make a new sheet for each job number. I'm pretty new to this, so I
don't even know if this is possible. Once the sheets are created, I've
got the data pulling macro working, but right now I have to create the
new sheets manually first. Thanks


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
Unable to access hyperlinked files. Jolibeanz Excel Discussion (Misc queries) 0 June 1st 10 03:28 PM
Working With Multiple hyperlinked files Shahar Marom Excel Discussion (Misc queries) 0 December 21st 09 01:15 AM
insert a hyperlinked TOC (of sheets) into Excel Geoff W Excel Discussion (Misc queries) 1 November 27th 08 01:41 AM
Keyboard freeze when using hyperlinked sheets FinController Excel Programming 0 February 16th 05 05:20 AM
How do I print hyperlinked files when selected from a check box? Tracy at CNC Excel Programming 0 December 9th 04 02:13 PM


All times are GMT +1. The time now is 08:58 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"