Hello all,
So i have a vba code that i use in other project and i want to adapt it to do something like this:
1. open newest file in given folder;
2. copy all sheets in current workbook after "MASTER" sheet;
3. close the newest file (the one from step one) without saving;
4. on each sheet from current workbook, text to columns (dd.mm.yyyy) the range from A21 to A1000;
5. Save the workbook without close.
My code is executing correctly step 1 and 2..
Any chance you could help me with the rest of the code?
This is what i have so far:
Thank you.
So i have a vba code that i use in other project and i want to adapt it to do something like this:
1. open newest file in given folder;
2. copy all sheets in current workbook after "MASTER" sheet;
3. close the newest file (the one from step one) without saving;
4. on each sheet from current workbook, text to columns (dd.mm.yyyy) the range from A21 to A1000;
5. Save the workbook without close.
My code is executing correctly step 1 and 2..
Any chance you could help me with the rest of the code?
This is what i have so far:
VBA Code:
Sub import()
Dim MyPath As String
Dim MyFile As String
Dim LatestFile As String
Dim LatestDate As Date
Dim LMD As Date
MyPath = "C:\Users\xxx\Desktop\yyy\"
If Right(MyPath, 1) <> "\" Then MyPath = MyPath & "\"
MyFile = Dir(MyPath & "*.xls", vbNormal)
If Len(MyFile) = 0 Then
MsgBox "No file!", vbExclamation
Exit Sub
End If
Do While Len(MyFile) > 0
LMD = FileDateTime(MyPath & MyFile)
If LMD > LatestDate Then
LatestFile = MyFile
LatestDate = LMD
End If
MyFile = Dir
Loop
Workbooks.Open MyPath & LatestFile, ReadOnly = True
Thank you.