lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
The first code, I used workbooks.open without () and excel did give me error message. In the second code, I had to use () otherwise I will get error message. Why is that? Thank you so much.
The first code, I used workbooks.open without () and excel did give me error message. In the second code, I had to use () otherwise I will get error message. Why is that? Thank you so much.
Rich (BB code):
Sub wb_open_using_collection()
Dim x As String
x = InputBox("enter file name with path")
Workbooks.Open Filename:=x
End Sub
Rich (BB code):
Sub ws_copy_to_closed_wb()
Dim x As Workbook
Dim y As String
y = InputBox("enter file name with path")
Set x = Workbooks.Open(Filename:=y)
Workbooks(1).Worksheets(1).Copy after:=x.Worksheets(1)
End Sub