ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Updating Worksheet Event Code Module via VBA (https://www.excelbanter.com/excel-programming/408096-updating-worksheet-event-code-module-via-vba.html)

Patrick4

Updating Worksheet Event Code Module via VBA
 
I have a large number of workbooks where I need to perform VBA code
maintenance.

I am updating all the code in the workbooks by first deleting all existing
code (modules, forms, worksheet code modules) and then import in the updated
modules / forms to to each work work.

I have one worksheet in each workbook ("Census") where I need to replace the
existing Worksheet_Change event code.

I already have the logic / process to remove all code from the workbooks and
import the updated modules / forms and worksheet code module.

Where I am stumped is how to import or add a updated Worksheet_Change event
code moulde.

Is there a way in VBA where I can import or enter the updated
worksheet_change event logic for the "Census" worksheet code module?

Any help would be greating appreciated!!!

Patrick


Bob Phillips

Updating Worksheet Event Code Module via VBA
 
You could try AddFromFile. Save the code in a text file and use this code

ActiveWorkbook.VBProject.VBComponents("ThisWorkboo k") _
.CodeModule.AddFromFile "C:\myTest\Text1.txt"

The problem is that you could add an event that is already present.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Patrick4" <u42287@uwe wrote in message news:817591d66e42a@uwe...
I have a large number of workbooks where I need to perform VBA code
maintenance.

I am updating all the code in the workbooks by first deleting all existing
code (modules, forms, worksheet code modules) and then import in the
updated
modules / forms to to each work work.

I have one worksheet in each workbook ("Census") where I need to replace
the
existing Worksheet_Change event code.

I already have the logic / process to remove all code from the workbooks
and
import the updated modules / forms and worksheet code module.

Where I am stumped is how to import or add a updated Worksheet_Change
event
code moulde.

Is there a way in VBA where I can import or enter the updated
worksheet_change event logic for the "Census" worksheet code module?

Any help would be greating appreciated!!!

Patrick




Barb Reinhardt

Updating Worksheet Event Code Module via VBA
 
This might help, but be careful!

http://www.cpearson.com/excel/vbe.aspx
--
HTH,
Barb Reinhardt



"Patrick4" wrote:

I have a large number of workbooks where I need to perform VBA code
maintenance.

I am updating all the code in the workbooks by first deleting all existing
code (modules, forms, worksheet code modules) and then import in the updated
modules / forms to to each work work.

I have one worksheet in each workbook ("Census") where I need to replace the
existing Worksheet_Change event code.

I already have the logic / process to remove all code from the workbooks and
import the updated modules / forms and worksheet code module.

Where I am stumped is how to import or add a updated Worksheet_Change event
code moulde.

Is there a way in VBA where I can import or enter the updated
worksheet_change event logic for the "Census" worksheet code module?

Any help would be greating appreciated!!!

Patrick



Patrick4 via OfficeKB.com

Updating Worksheet Event Code Module via VBA
 
These didn't work for my current circumstance but I'll keep them for my
toolkit becuase they were for workbook-level events.

The event logic I am trying to add is the Worksheet_Change event associated
with the "Census" worksheet in each of the workbooks.

--
Message posted via http://www.officekb.com


Patrick4 via OfficeKB.com

Updating Worksheet Event Code Module via VBA
 
Using the logic from cpearson using a workbook event worked. Thanks for the
help.

--
Message posted via http://www.officekb.com



All times are GMT +1. The time now is 08:00 PM.

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