ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding VB code to worksheet programatically (https://www.excelbanter.com/excel-programming/357502-adding-vbulletin-code-worksheet-programatically.html)

seegerp

Adding VB code to worksheet programatically
 
I have an Excel VB program which creates new worksheets from other Excel
worksheets. But, I would like to programatically add VB code to the newly
created worksheet such that when I double click on one of the cells in the
created worksheet I have specific VB code run that does some additional
processing.

What I do now is each time I run my VB code, which creates the new
worksheets, I have to go to each new sheet and add a procedure line to the
worksheet. See below:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
MyTest
End Sub

Would like some code to add the "MyTest" code to the new worksheet without
me having to add it manually.

The MyTest proc allready exists and works.

How do I do this?

Chip Pearson

Adding VB code to worksheet programatically
 
See www.cpearson.com/excel/vbe.htm for details and example code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"seegerp" wrote in message
...
I have an Excel VB program which creates new worksheets from
other Excel
worksheets. But, I would like to programatically add VB code to
the newly
created worksheet such that when I double click on one of the
cells in the
created worksheet I have specific VB code run that does some
additional
processing.

What I do now is each time I run my VB code, which creates the
new
worksheets, I have to go to each new sheet and add a procedure
line to the
worksheet. See below:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range,
Cancel As
Boolean)
MyTest
End Sub

Would like some code to add the "MyTest" code to the new
worksheet without
me having to add it manually.

The MyTest proc allready exists and works.

How do I do this?




Gazeta

Adding VB code to worksheet programatically
 

Użytkownik "seegerp" napisał w
wiadomości ...
I have an Excel VB program which creates new worksheets from other Excel
worksheets. But, I would like to programatically add VB code to the newly
created worksheet such that when I double click on one of the cells in

the
created worksheet I have specific VB code run that does some additional
processing.

What I do now is each time I run my VB code, which creates the new
worksheets, I have to go to each new sheet and add a procedure line to the
worksheet. See below:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
MyTest
End Sub

Would like some code to add the "MyTest" code to the new worksheet without
me having to add it manually.

The MyTest proc allready exists and works.

How do I do this?


you should find it there
http://www.cpearson.com/excel/vbe.htm
mcg




All times are GMT +1. The time now is 10:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com