Start from Sheet 1

omkar94

New Member
Joined
Apr 26, 2017
Messages
24
Hi Guys,

I need a VBA code that when executed it will do as mentioned below:

- When I click on 'add sheet' button It will start from Sheet 1, instead of Sheet (x).


Please let me know if this is possible or if you need any clarification from my end.

Thanks a ton.
 
Last edited:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi guys, not sure if above message is confusing. Please ignore and read the revised version.

My below current code deletes all the sheets except "Generate Tables" sheet.
Can someone help modify it so once code is executed it will do as mentioned below:

- When I click on 'add sheet (+)' button It will start from Sheet 1, instead of Sheet (x).
- (x) = last known sheet number + 1

Please let me know if this is possible or if you need any clarification from my end.

Current Code:


Dim xWs As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In Application.ActiveWorkbook.Worksheets
If xWs.Name <> "Generate Tables" Then
xWs.Delete
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True


Thanks again.
 
Upvote 0

Forum statistics

Threads
1,215,990
Messages
6,128,158
Members
449,428
Latest member
d4vew

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top