I have the following Excel VBA code.
I already copied some data from another Excel document. I need to paste these date in a second document that contains an Excel sheet for every week.
The Excel sheets are called "week 01", "week 02", "..." , "week 52".
Now I need to select the sheet with the correct number to paste my copied data there.
Sub Macro1()
Dim number As String
Dim year As String
number = Application.InputBox(Prompt:="insert week number (01-52))", Type:=2)
year = Application.InputBox(Prompt:="insert year (YYYY)", Type:=2)
Workbooks.Open Filename:= _
"F:\documents\" & year & "\example " & number & ".xlsm"
Sheets("Week" number).Select
Range("M4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
I know that the following code isn't correct. How can I select the correct excel sheet, using the variable "number"?
Sheets("Week" number).Select