ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programmatically adding code to worksheet (https://www.excelbanter.com/excel-programming/405854-programmatically-adding-code-worksheet.html)

Raj[_2_]

Programmatically adding code to worksheet
 
Hi,

When I need to add code to a worksheet, I rightclick on the sheet tab
bearing the sheetname, choose "View Code" and, paste the code.

Is there a way to do this programmatically as I have to insert the
worksheet code in 65 sheets.

Thanks in advance for the help.

Raj

Gary Keramidas[_2_]

Programmatically adding code to worksheet
 
see if this helps

http://www.cpearson.com/excel/vbe.aspx

--

Gary


"Raj" wrote in message
...
Hi,

When I need to add code to a worksheet, I rightclick on the sheet tab
bearing the sheetname, choose "View Code" and, paste the code.

Is there a way to do this programmatically as I have to insert the
worksheet code in 65 sheets.

Thanks in advance for the help.

Raj



Gord Dibben

Programmatically adding code to worksheet
 
Is it the same code to added to all 65 sheets?

Add it once in Thisworkbook module to cover all sheets.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
your code
End Sub


Gord Dibben MS Excel MVP

On Sat, 9 Feb 2008 16:34:08 -0800 (PST), Raj wrote:

Hi,

When I need to add code to a worksheet, I rightclick on the sheet tab
bearing the sheetname, choose "View Code" and, paste the code.

Is there a way to do this programmatically as I have to insert the
worksheet code in 65 sheets.

Thanks in advance for the help.

Raj



Gord Dibben

Programmatically adding code to worksheet
 
Make that "to BE added to all 65 sheets"


Gord

On Sat, 09 Feb 2008 16:45:16 -0800, Gord Dibben <gorddibbATshawDOTca wrote:

Is it the same code to added to all 65 sheets?

Add it once in Thisworkbook module to cover all sheets.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
your code
End Sub


Gord Dibben MS Excel MVP

On Sat, 9 Feb 2008 16:34:08 -0800 (PST), Raj wrote:

Hi,

When I need to add code to a worksheet, I rightclick on the sheet tab
bearing the sheetname, choose "View Code" and, paste the code.

Is there a way to do this programmatically as I have to insert the
worksheet code in 65 sheets.

Thanks in advance for the help.

Raj



Raj[_2_]

Programmatically adding code to worksheet
 
On Feb 10, 5:53 am, Gord Dibben <gorddibbATshawDOTca wrote:
Make that "to BE added to all 65 sheets"

Gord

On Sat, 09 Feb 2008 16:45:16 -0800, Gord Dibben <gorddibbATshawDOTca wrote:
Is it the same code to added to all 65 sheets?


Add it once in Thisworkbook module to cover all sheets.


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
your code
End Sub


Gord Dibben MS Excel MVP


On Sat, 9 Feb 2008 16:34:08 -0800 (PST), Raj wrote:


Hi,


When I need to add code to a worksheet, I rightclick on the sheet tab
bearing the sheetname, choose "View Code" and, paste the code.


Is there a way to do this programmatically as I have to insert the
worksheet code in 65 sheets.


Thanks in advance for the help.


Raj


Thanks, Gary and Gord. I will study the excellent resource given by
Gary. I am sure that I will find my solution there.

Gord, I omitted to say something in my first post. The 65 sheets are
in 65 DIFFERENT workbooks but have the same name ("Data") in all
workbooks. Any quick code for that?

Thanks, once again.
Raj


All times are GMT +1. The time now is 12:05 PM.

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