Dear all,
How can I defined a marco which can search the latest file in the folder (in the floder = C:\test folder, file name = test_1.xls, test_2.xls,...), then copy a sheet to the other excel file's sheet (Original.xls -> sheets("Original"))?
I defined a marco which can search the last data in a file then let me can auto-copy the latest file data to the file.
Sub test()
'
' test Macro
'
' Keyboard Shortcut: Ctrl+u
'
Sheets("Original").Select
' Find the last row of data
finalrow = Range("A1048576").End(xlUp).Row
'Loop Through each row
For x = 5 To finalrow
'decide if to copy based on column C
thisvalue = Range("C" & x).Value
If thisvalue = "" Then
End If
Next
'I want to search the latest file in the folder, and the path should be the latest file eg. c:\test folder\test_1.xls
Workbooks.Open Filename:="C:\test folder\test.xls", UpdateLinks:=0
Sheets("Sheet1").Select
Range("A5:T1000").Select
Selection.Copy
Windows("Original.xlsm").Activate
Sheets("Original").Select
NextRow = Range("A1048576").End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Windows("test.xls").Activate
ActiveWindow.Close
End Sub
Thanks all and Best regards