Microsoft Excel VBA development

Anonymous

Veteran
I'm programming an custom hours manager based in Microsoft Excel and I've run into a problem. What I'm doing is making a selected cell resize for better readability of data validation. To detect a change, I am using the Worksheet_SelectionChange event. While the code itself works well, is there a way to make the code automatically work when a new worksheet is added by somehow detecting whan a cell selection is changed throughout the entire workbook or modifying the worksheet code using a macro. Any ideas?

Also, does anyone know a good forum for "programming" :rolleyes: in VBA.
 
Don't really know much about this, but isn't the code stored as part of the worksheet? In which case it can't really do anything on worksheet creation as it doesn't exist at that point.

Can you do something similar to Word, where you create a template document which you then choose to create one of your custom type (which will be preformated the way you want as well as having your vba code).

CC
 
I'm not creating a whole new workbook here as you would in MS Word but rather am adding another sheet to which I want the code added. I will see if it is possible to do something similar to the worksheets in a workbook, however. If this doesn't work I'll just have to create a custom macro that work with all the sheets.
 
there is as well an application SheetSelectionChange event, so this might make your macro run every time you change selection anywhere...
 
Tried it and it works. I though that the SheetSelectionchange event refered to activating a sheet so I didn't try it.

Thanks,
Sworkhard
 
Just FYI...the reason it works is because adding a sheet also activates the new sheet automatically...and hence, it triggers the SheetSelectionchange event.
 
Back
Top