lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I want to add a sheet but I want to keep sheet1 as an active one. I named sheet1 as "Hello". Now when I run the code below, it will do these 2 things
1) Adding a sheet before sheet1! why is that? In excel when I click + to add a sheet, it will add it after the active one not before like what vba is doing
2) the code will activate the new sheet that is created but not my first sheet which is called "Hello".
How can I fix that, I want to add a sheet but keep sheet1 activated. Thank you so much
I want to add a sheet but I want to keep sheet1 as an active one. I named sheet1 as "Hello". Now when I run the code below, it will do these 2 things
1) Adding a sheet before sheet1! why is that? In excel when I click + to add a sheet, it will add it after the active one not before like what vba is doing
2) the code will activate the new sheet that is created but not my first sheet which is called "Hello".
How can I fix that, I want to add a sheet but keep sheet1 activated. Thank you so much
Code:
Sub worksheet_add()
Workbooks(1).Worksheets.Add
Workbooks(1).Worksheets(1).Activate
End Sub