lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
The code below is working. I have 2 workbooks. Workbooks(1) has the code. When the user enter x = 2
the code below will create a worksheet in Workbooks(2) after worksheets(1). It is working but I wonder, in line 4, why I did not have to do this
It will create the sheet in workbooks(2) anyway. Is that because of Workbooks(x=2).worksheets.Add? Thank you very much.
The code below is working. I have 2 workbooks. Workbooks(1) has the code. When the user enter x = 2
the code below will create a worksheet in Workbooks(2) after worksheets(1). It is working but I wonder, in line 4, why I did not have to do this
Rich (BB code):
Workbooks(x).Worksheets.Add after:=Workbooks(x).Worksheets(1)
It will create the sheet in workbooks(2) anyway. Is that because of Workbooks(x=2).worksheets.Add? Thank you very much.
Rich (BB code):
Sub ws_add_using_collection()
Dim x As Integer
x = InputBox("which book")
Workbooks(x).Worksheets.Add after:=Worksheets(1)
End Sub