lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I opened file A.xlsxm and wrote the code below. I ran the code and entered B.xlsx. The code below did not work until I changed the 5th line to the following
Why workbooks(2).sheet1 did not work? I also tried to use the Immediate window, and tried after opening B.xlsx
?Sheet1.name --> got A.xlsx
then tried
?workbooks(2).Sheet1.name --> got error message
In project window, I see both A and B have Sheet1 before the move. Thank you.
I opened file A.xlsxm and wrote the code below. I ran the code and entered B.xlsx. The code below did not work until I changed the 5th line to the following
Rich (BB code):
Sheet1.Move before:=Workbooks(2).Sheets(1)
Rich (BB code):
Sub abc()
Dim x As String
x = InputBox("file")
Workbooks.Open (x)
Sheet1.Move before:=Workbooks(2).Sheet1
End Sub
Why workbooks(2).sheet1 did not work? I also tried to use the Immediate window, and tried after opening B.xlsx
?Sheet1.name --> got A.xlsx
then tried
?workbooks(2).Sheet1.name --> got error message
In project window, I see both A and B have Sheet1 before the move. Thank you.