hansgrandia
Board Regular
- Joined
- Jan 10, 2015
- Messages
- 53
Hello,
Despite the below standing code (Private Sub Process_XLS_Files) copies a date like 2-1-2017 it turns it into 1-2-2017. I have tried to get it fixed by add in an extra piece of code, but that did not help. Both with function of Dateformat as Numberformat.
Look forward to your reply. Hans Grandia NL
Despite the below standing code (Private Sub Process_XLS_Files) copies a date like 2-1-2017 it turns it into 1-2-2017. I have tried to get it fixed by add in an extra piece of code, but that did not help. Both with function of Dateformat as Numberformat.
Look forward to your reply. Hans Grandia NL
Code:
'Date format to "dd-mm-yyyy"
Sheets(1).Delete 'voorblad
For Each wksht In Workbooks
Rowcounter = Application.CountA(Range("A:A"))
Range("A2", "A & Rowcounter").NumberFormat = "dd-mm-yyyy"
Next wksht
Code:
Private Sub Process_XLS_Files(Fso As Scripting.FileSystemObject, folderPath As String)
Dim Folder As Scripting.Folder, Subfolder As Scripting.Folder, File As Scripting.File
Dim wksht As Worksheet
Dim Masterfile As Workbook
Dim Rowcounter As Long
Set Folder = Fso.GetFolder(folderPath)
For Each wksht In ActiveWorkbook.Worksheets
For Each Subfolder In Folder.SubFolders
For Each File In Subfolder.Files
If InStr(File.Name, ".xls") Then
Workbooks.Open (File.Path)
On Error Resume Next
Worksheets(wksht.Name).Select
If Err.Number = 0 Then
Range(Range("A14"), Range("A14").End(xlDown)).Select
ActiveCell.CurrentRegion.Select
Selection.Copy
ActiveWorkbook.Close
Worksheets(wksht.Name).Activate
Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Else
On Error GoTo 0
ActiveWorkbook.Close
End If
End If
Next
Next
Next wksht