Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub workbookopen()
Dim rng As Range, cell As Range Dim sStr As String, sStr1 As String Dim sPath As String Dim sArrPath(1 to 2) as String Dim rngArr(1 to 2) as Range Dim wkbk As Workbook sArrPath(1) = "F:\mydir1\mydir2\" sArrPath(2) = "C\Myfiles\" With Worksheets("List") Set rngArr(1) = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown)) End With With Worksheets("List2") Set rngArr(2) = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown)) End With for i = 1 to 2 sPath = sArrPath(i) set rng = rngArr(i) For Each cell In rng sStr = cell.Value sStr1 = Dir(sPath & sStr & "*.xls") If sStr1 < "" Then Set wkbk = Workbooks.Open(sPath & sStr1) End If Next cell Next i End Sub -- Regards, Tom Ogilvy "Starting to Program" wrote in message ... The following macro was written by Tom, I wondered if anyone (Tom?) could help in extending it? What I need to do is instead of having 1 list of files I need 2 (as in different directories) Can anyone help. The Macro (that works for one list is below...) Sub workbookopen() Dim rng As Range, cell As Range Dim sStr As String, sStr1 As String Dim sPath As String Dim wkbk As Workbook sPath = "F:\mydir1\mydir2\" With Worksheets("List") Set rng = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown)) End With For Each cell In rng sStr = cell.Value sStr1 = Dir(sPath & sStr & "*.xls") If sStr1 < "" Then Set wkbk = Workbooks.Open(sPath & sStr1) End If Next End Sub Thanks. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel development tools? | Excel Discussion (Misc queries) | |||
New Excel development | Excel Discussion (Misc queries) | |||
Development tool,Excel,GUI | Excel Discussion (Misc queries) | |||
EXCEL MACRO DEVELOPMENT | Excel Programming | |||
Development hours (off topic) | Excel Programming |