Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When I insert a sheet in my workbook, there must be (simple) PrivateSub
added to that Sheet. Can that be done? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
http://www.cpearson.com/excel/vbe.htm
-- Regards, Tom Ogilvy "Gert-Jan" wrote: When I insert a sheet in my workbook, there must be (simple) PrivateSub added to that Sheet. Can that be done? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() It can be done. Example ( in ThisWorkbook code module): Const SheetCode As String = _ "Private Sub Worksheet_SelectionChange(ByVal Target As Range)" & vbCrLf & _ "Call MySelectionChange(Target)" & vbCrLf & _ "End Sub" Private Sub Workbook_NewSheet(ByVal Sh As Object) Dim comp As VBComponent Dim LineNum As Long With ThisWorkbook.VBProject.VBComponents(Sh.CodeName) If .type = vbext_ct_Document Then With .CodeModule LineNum = .CountOfLines + 1 .InsertLines LineNum, SheetCode End With End If End With End Sub __________________________________________________ _______________________ To gain access to this class go to the Tools menu in the VBA editor, choose the References item, and put a check next to "Microsoft Visual Basic For Applications Extensibility" library. If you need more details:I got this wisdom he http://www.cpearson.com/excel/vbe.htm Met vriendelijke groeten, Lex |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
how to count/sum by function/macro to get the number of record to do copy/paste in macro | Excel Programming | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |