Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Open files from folder by matching name

Hi Again

First off sorry my first code didn't work for you, not sure why as i
tested it and it runs fine for me with the info from your post? Anywho
i can't think of a way around it using your proposed method however i
have come up with a sort of combo of the two, this time without the
FSO but still using the InStr function as i think this is the easiest
way to check for a name in a string...

I have added a few escape routes to try and get out of the loops to
prevent unnecessary cycles, let me know how you get on with the code
and of course if you find a way around the problem :)

Dim fldrName As String
Dim fName
Dim lastcl As Integer
Dim i As Integer
Dim intFound As Integer

Sub test()
fldrName = "C:\Record"
fName = Dir(fldrName & "\*.xls")
With Workbooks("Data.xls")
lastcl = .Sheets("Sheet1").Cells _
(Rows.Count, "A").End(xlUp).Row
Do While fName < ""
For i = 1 To lastcl
If InStr(1, fName, .ActiveSheet.Cells(i, 1).Value, _
vbTextCompare) < 0 Then
Workbooks.Open (fldrName & "\" & fName)
intFound = intFound + 1
i = lastcl
End If
Next i
fName = Dir()
If intFound = lastcl Then Exit Do
Loop
End With
End Sub


Steve
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
User selection of folder and open all .xls files within folder Barb Reinhardt Excel Programming 4 April 14th 07 01:41 PM
Open all files in folder automatically using VBA [email protected] Excel Programming 4 September 2nd 05 02:58 PM
Open files in folder - skip if already open Steph[_3_] Excel Programming 6 March 25th 05 06:49 PM
Open all files in a folder Daniel Van Eygen Excel Programming 5 August 24th 04 04:48 PM
open all files in a folder and ... walt Excel Programming 5 August 7th 03 02:23 AM


All times are GMT +1. The time now is 03:47 AM.

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

About Us

"It's about Microsoft Excel"