Dutchmaste
New Member
- Joined
- Jun 14, 2016
- Messages
- 23
- Office Version
- 365
- Platform
- Windows
I currently use the below macro. But as shown on line 7 & 15 this only looks for a filename with .xlsx
But unfortunatelly sometimes the extension of the files I receive change into either .xls, .xlsx or .xlsm
Due to this I currently have to edit the macro manually to look for the other extension. But I want it to do this automatically. But I can't seem to figure it out so it works for both actions on line 7 and 15.
But unfortunatelly sometimes the extension of the files I receive change into either .xls, .xlsx or .xlsm
Due to this I currently have to edit the macro manually to look for the other extension. But I want it to do this automatically. But I can't seem to figure it out so it works for both actions on line 7 and 15.
Code:
Line1: Dim curWorkbook As WorkbookLine2: Set curWorkbook = ActiveWorkbook
Line3: Application.AskToUpdateLinks = False
Line4: Application.DisplayAlerts = False
Line5: fName = curWorkbook.Sheets("HS Lijst").Range("K2")
Line6: Sheets("DATA").Select
Line7: Workbooks.Open FileName:="O:\Splitsen\" & fName & ".xlsx"
Line8: Cells.Select
Line9: Selection.Copy
Line10: curWorkbook.Activate
Line11: Cells.Select
Line12: ActiveSheet.Paste
Line13: Sheets("HS lijst").Select
Line14: Range("C4").Select
Line15: Windows(fName & ".xlsx").Activate
Line16: Application.CutCopyMode = False
Line17: ActiveWindow.Close
Line18: Application.CutCopyMode = True
Line19: curWorkbook.Activate
Line20: Application.DisplayAlerts = True
Line21: Application.AskToUpdateLinks = True