I'm new to using VBA, and don't really understand a lot of terminology yet, so please bear with me.
Using the record macro function, I've got the below macro:
Sub CFData()
'
' CFData Macro
'
'
Sheets("CF Data").Select
Range("J5").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents
Range("B5").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
Range("J5").Select
ActiveSheet.Paste
Range("B5").Select
Workbooks.Open Filename:= _
"W:\\Shared\Config&Planning\CF Data.xlsx"
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Windows("Template 2105.xlsx").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("CF Data.xlsx").Activate
Application.CutCopyMode = False
ActiveWindow.Close
End Sub
I'm using it to copy a range of data that is automatically updated each morning, and paste it into the active workbook, which is saved with a new name each day (eg "Template 2105" today, "Template 2205" tomorrow etc). Having recorded the macro though, it doesn't recognise a different file name when selecting the window. I know there's obviously a much better way to write this, but I have no idea what needs to change.
Many thanks