At my work I manually copy sales forecast into another file that gets uploaded to our website. The two files I manually copy have the same exact layout everytime (no cells are changing positions) but the name of the file changes due to having different products every day.
I tried the VBA record button but since the file changes its name everyday then it becomes useless, since it would require me to change the name of the file in every sentence. Can I somehow define the name of the file in the beginning so I only have to change that when I run the macro?
Sub Test2()
' Test2 Macro
Dim FileName As String
FileName = ""
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select File"
.Filters.Add "Excel File", "*.xls?"
.AllowMultiSelect = False
If .Show Then
FileName = .SelectedItems(1)
End If
End With
If Len(FileName) < 4 Then Exit Sub 'No file selected
Dim TempWorkbook As Workbook
Set TempWorkbook = Workbooks.Open(FileName, ReadOnly:=True)
ActiveSheet.Range("U8").FormulaR1C1 = "=" & TempWorkbook.Worksheets("FINAL FORM").Cells(18, 2).Address(True, True, xlR1C1, True)
TempWorkbook.Close SaveChanges:=False
Set TempWorkbook = Nothing
End Sub
For example somehow define [MNY FDL CS Lifter Lip.xlsx] to "wb1" and then have that in the following sentences so I only have to change the name in the define sentence?