Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Open files by looking at list names in column A

Try this simple approach. Skips blanks

Sub OpenFilesInList()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
On Error Resume Next
For Each wb In Range("a1:a" & lastrow)
Workbooks.Open Filename:="C:\documents\records\" & wb & ".xls"
Next wb
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"K" wrote in message
...
Hi all, I got names in column A of Workbooks("Summary.xls").Sheets
("Sheet1") like see below

A………….col
John
Vikki
Ali
Sophy
Dean

In folder "C:\Documents\Records" I have two files like see below

Record for John
Record for Sophy

I want macro which should match names of column A with the file names
and if exist then it should open that file. I wrote below macro which
only opening file with name "Record of John" as it should also open
"Record for Sophy" because the name Sophy also exist in column A
list. Please can any friend help that whats wrong with macro below

Sub Test()
fldrName = "C:\Documents\Records"
With Workbooks("Summary.xls").Sheets("Sheet1")
lastcl = .Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = 2 To lastcl
If .Range("A" & RowCount) < "" Then
pnm = .Range("A" & RowCount).Value
fName = Dir(fldrName & "\" & "*" & pnm & "*.xls")
If fName = "" Then GoTo lastmsg
Set bk = Workbooks.Open(Filename:=fldrName & "\" & fName)
End If
fName = Dir()
Next
End With
lastmsg:
MsgBox "Its Done!", vbInformation, "Done"
End Sub

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 / close files and display names Jack Excel Programming 3 July 3rd 09 03:12 AM
How to create a list of media files names in excel. joye68 Excel Discussion (Misc queries) 2 July 9th 07 05:12 AM
Excel 2003 - When I open files, why are some file names blue? Formula One Excel Discussion (Misc queries) 2 August 17th 06 05:58 PM
create a list of worksheet names (from a single folder, or open files) Drew Excel Discussion (Misc queries) 2 April 15th 05 04:58 PM
Change names of files in a folder to match names in Excel Column saybut Excel Programming 4 February 9th 04 06:26 PM


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

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"