When I enter a new worksheet into a workbook (Alt+i+w), Excel always puts it to the left of the active worksheet. Is there an easy way to make it insert on the right? That seems to be where I always want it. Right now I just drag it over, which isn’t too much of a pain. But just for fun, I thought I’d write a macro to move it for me.
I added a class module named CAppEvent to Personal.xls with this code:
Private Sub myApp_WorkbookNewSheet(ByVal Wb As Workbook, ByVal Sh As Object)
Sh.Move , Wb.Sheets(Sh.Index + 1)
And added a variable to a standard module:
And added this code to the ThisWorkbook module:
Set gclsApp = Nothing
Private Sub Workbook_Open()
Set gclsApp = New CAppEvent
Set gclsApp.myApp = Application
Is there some way that event code can fail?
Update: See Part II