lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I have 3 sheets named 1,2,3 and I am moving them around using the code below. sheet name "2" has the button which run the code. I want to do the move but keep going back to sheet("2"). I did it as below. How you would do it yourself? Is that good and efficient programming? Thank you so much
I have 3 sheets named 1,2,3 and I am moving them around using the code below. sheet name "2" has the button which run the code. I want to do the move but keep going back to sheet("2"). I did it as below. How you would do it yourself? Is that good and efficient programming? Thank you so much
Code:
Sub movesheet()
Dim x As Integer
Dim y As Integer
x = InputBox("sheet to move")
y = InputBox("after which sheet")
Workbooks(1).Worksheets(x).Move after:=Worksheets(y)
Workbooks(1).Worksheets("2").Activate
End Sub