I am new to VBA and I want to add a link with a variable inside.
I have to open many files from an online sharepoint. The link changes every month as it needs to open a different file. So I need to create a variable inside the link so I can specify the link for each month.
Sub open_file_demo()
' declare variable
Dim pathname
Dim month As String
' assign a value
pathname = "https://sharepoint.com/sites/XXX/XXX/XXX/XXX/2022/06.xlsx?web=1"
' now open the file using the open statement
Workbooks.Open pathname
End Sub
So I want to have the filename (06.xlsx) to be declared from lets say A1 in the document