PDA

View Full Version : excel multiple workbooks



shaneceltic
05-03-2010, 06:06 AM
...i've choice of 4?ideas

lynnnow
05-03-2010, 06:13 AM
Shaneceltic, you have not provided enough information on where the files are stored, or the date format or other relevant explanation on how to solve your query. Please be a bit more specific.

shaneceltic
05-03-2010, 07:49 AM
,

mdmackillop
05-03-2010, 08:07 AM
Something like this, suited to your date format

Dim FName
FName = InputBox("Enter Day & Month" & vbCr & "e.g. 0102") & "2010timetable.xls)"
Workbooks.Open ("C:\" & FName)

shaneceltic
05-03-2010, 08:38 AM
thanks mate, i just can't seem to get the file path to work, keeps giving same 1004 runtime error

mdmackillop
05-03-2010, 09:07 AM
What value do you see for fname?

shaneceltic
05-03-2010, 10:24 AM
what comes up is: the path i'm using, e.g C:\Documents\02032010timetable.xls
the path is correct and everything else seems to be fine. i've tried declaring mypath as a const aswell, didn't change anything

shaneceltic
05-03-2010, 10:26 AM
got it running, there was a ) in " " of filename

shaneceltic
05-03-2010, 10:27 AM
last

mdmackillop
05-03-2010, 10:42 AM
Option Explicit
Sub GetAllSheets()

Dim FName$, Dy$, Mth$, Dys$, i%
FName = InputBox("Enter Day & Month / Days" & vbCr & "e.g. 0102/6")
Dy = Left(FName, 2)
Mth = Mid(FName, 3, 2)
Dys = Split(FName, "/")(UBound(Split(FName, "/")))
For i = 0 To Dys
FName = Format(Dy + i, "00") & Mth & "2010timetable.xls"
Workbooks.Open ("C:\" & FName)
Next
End Sub

shaneceltic
05-03-2010, 11:24 AM
worked perfectly.thanks a million, i haven't come across the Ubound command before??

mdmackillop
05-03-2010, 11:35 AM
Split creates an array. Ubound (array) returns the last element of an array.