I have a workbook "Book1" which opens a second workbook with this code:
What i need to do is copy all rows from a worksheet on "DailySchedules" called "Works". I need to copy all rows that contain tomorrows date in column F of this worksheet (formatted as "d-mmm-yyyy").
I need to copy all these cells to a worksheet on "MainWorkBook" called "Sheet1", starting at cell "A1". I also want to keep all formatting of everything copied.
The data on worksheet "Works" in workbook "DailySchedules" starts at row 4 (as there is a header on the first 3 rows) and can be an unknown nuber of rows down.
I have indicated in the code above where i need the code to be inserted but do not know how to do what is required.
TIA
Code:
option explicit
Global MainWorkBook As Workbook
Global DailySchedules As Workbook
Sub OpenDailyScheduleWorkbook()
Dim Filename As String
Dim response As String
Set MainWorkBook = ActiveWorkbook
Application.StatusBar = "IMPORTING WORKBOOK DATA ...PLEASE WAIT..."
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Filename = Application.GetOpenFilename(FileFilter:="Excel Files,*.xls", Title:="Please choose Workbook to open")
If Not Chk(Filename) Then
'If Filename = "False" Then
response = MsgBox("No file selected" & Chr(10) & "procedure cancelled!", 48, "Error")
Exit Sub
Else: Set DailySchedules = Workbooks.Open(Filename)
End If
Application.DisplayAlerts = False
' CODE NEEDED HERE !!
DailySchedules.Close False
Application.StatusBar = "Ready"
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Function Chk(myFile As String) As Boolean
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Chk = fso.FileExists(myFile)
Set fso = Nothing
End Function
What i need to do is copy all rows from a worksheet on "DailySchedules" called "Works". I need to copy all rows that contain tomorrows date in column F of this worksheet (formatted as "d-mmm-yyyy").
I need to copy all these cells to a worksheet on "MainWorkBook" called "Sheet1", starting at cell "A1". I also want to keep all formatting of everything copied.
The data on worksheet "Works" in workbook "DailySchedules" starts at row 4 (as there is a header on the first 3 rows) and can be an unknown nuber of rows down.
I have indicated in the code above where i need the code to be inserted but do not know how to do what is required.
TIA