Hi,
Does any one help me to get a vba code that meets the below mentioned requirements,
I want to copy certain rows from different workbook to a master copy, but the criteria for the selection of row from the work books is based on the date entered on the left most cell of the rows . and all work books follow the uniform structure. It would be great if I could enter a date in the input box and then the macro copy the rows with that particular date in the left most column. Please find below the snapshot of the work book that needs to be copied.
Date work type 1 work type 2 work type 3 work type 4 work type 5
14-Jan-15 14 15 16 14 14
15-Jan-15 36 37 45 32 11
I got a vba code that partially fills my requirement. But that requires manually editing of the range in the macro code. Seems a message box to enter either the the range or the date , and the macro runs based on the inputs will fulfill my requirement.
Sub Import_to_Master()
Dim sFolder As String
Dim sFile As String
Dim wbD As Workbook, wbS As Workbook
Application.ScreenUpdating = False
Set wbS = ThisWorkbook
sFolder = wbS.Path & "\"
sFile = Dir(sFolder)
Do While sFile <> ""
If sFile <> wbS.Name Then
Set wbD = Workbooks.Open(sFolder & sFile) 'open the file; add condition to
' >>>>>> Adapt this part
wbD.Sheets("Sheet1").Range("A3:H3").Copy
wbS.Activate
Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
' >>>>>>
wbD.Close savechanges:=True 'close without saving
End If
sFile = Dir 'next file
Loop
Application.ScreenUpdating = True
End Sub
Thanking you in advance,
Regards,
Lijith
Bookmarks