ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I insert/update VBA code into a sheet? (using a CLS file?) (https://www.excelbanter.com/excel-programming/277000-re-how-do-i-insert-update-vba-code-into-sheet-using-cls-file.html)

Chip Pearson

How do I insert/update VBA code into a sheet? (using a CLS file?)
 
Peter,

See www.cpearson.com/excel/vbe.htm for examples.


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


"Peter McNaughton" wrote in message
om...
Hi,
I have a file WORKBOOK.xls with a a number of sheets, one of which is
WORKINGS.
I wish to change the existing code which consisted only of
Worksheet_BeforeRightClick(...) and Worksheet_BeforeDoubleClick(...)
with 2 new procedures Worksheet_Actvate(...) and
Worksheet_Deactivate(...).

I have created a CLS file but don't know how to replace the existing
code with the contents of Workings.cls.

I also wish to add similar code into another sheet which doesn't have
any code.

Would appreciate some guideance

Peter

Workings.Cls follows:

Attribute VB_Name = "Workings"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True

Private Sub Worksheet_Activate()
Me.Protect userinterfaceonly:=True
If Application.StatusBar = "Preview Materials By Category..." Then
Else
If hasPreconstructionRights Or hasContractSignRights Then
Else
ActiveWindow.SelectedSheets.Visible = False
End If
End If
End Sub

Private Sub Worksheet_Deactivate()
If Application.StatusBar = "Preview Materials By Category..." Then
Application.StatusBar = False
Else
If hasPreconstructionRights Or hasContractSignRights Then
ActiveWindow.SelectedSheets.Visible = False
Else
End If
End If
End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range,
Cancel As Boolean)
Call WorkingsWorksheet_BeforeDoubleClick(Target, Cancel)
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range,
Cancel As Boolean)
Call WorkingsWorksheet_BeforeRightClick(Target, Cancel)
End Sub





All times are GMT +1. The time now is 11:55 AM.

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