antonioking
asked on
if workbooks worksheets name is a date between date range, copy data to another workbook.
Please can someone help me.
I would like a macro that will open a workbook, and check the names of all the sheets in the workbook.
all names in the workbook follow the format... "CHAPS dd.mm.yy"
Where dd mm yy is a date.
If the name of the sheet is between specfied dates dteReportDate1 and dteReportDate2 then copy rows 3 onwards to the original workbook worksheet name "CHAPSWEEK1"
If there is already date on CHAPSWEEK1 the copied date should be appended to the sheet.
I would like a macro that will open a workbook, and check the names of all the sheets in the workbook.
all names in the workbook follow the format... "CHAPS dd.mm.yy"
Where dd mm yy is a date.
If the name of the sheet is between specfied dates dteReportDate1 and dteReportDate2 then copy rows 3 onwards to the original workbook worksheet name "CHAPSWEEK1"
If there is already date on CHAPSWEEK1 the copied date should be appended to the sheet.
Sub RunCHAPSImport()
Dim strImportWorkBookName As String
Dim dteReportDate1 as Date
Dim dteReportDate2 as Date
Dim wbActiveWorkbook as Workbook
Set wbActiveWorkbook = ThisWorkbook
Set dteReportDate1 = "28/02/11"
Set dteReportDate1 = "07/03/11"
Application.DisplayAlerts = False
Set strImportWorkBookName = Workbooks.Open(Filename:="C:\InputFolder\CHAPS.xls")
Application.DisplayAlerts = True
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
type mismatch on line
dt = DateSerial(myarray(2), myarray(1), myarray(0))
dt = DateSerial(myarray(2), myarray(1), myarray(0))
Sorry try this
dt = DateSerial(Val(Trim(myarra y(2))), Val(Trim(myarray(1))), Val(Trim(myarray(0))))
Sid
dt = DateSerial(Val(Trim(myarra
Sid
ASKER
Now getting subscript out of range on that line. thanks
Can you upload the file so that I can test?
Sid
Sid
Sid