Здравствуйте
переименовал кнопки в Digit0 .. Digit9, удалил код, привязанный к кнопкам
в модуле класса ClDigitalButtons
[vba]Код
Private WithEvents cb As CommandButton
Private cell As Range
Public Sub Init(ctrl As CommandButton, r As Range)
Set cb = ctrl
Set cell = r
End Sub
Private Sub Class_Terminate()
Set cb = Nothing
Set cell = Nothing
End Sub
Private Sub cb_Click()
cell = cell.Value & cb.Caption
End Sub
[/vba]в стандартном модуле
[vba]Код
Dim colButtons As Collection
Sub hookButtons(ws As Object)
Dim dBtn As ClDigitalButtons
Dim obj As OLEObject
Set colButtons = New Collection
For Each obj In ws.OLEObjects
If TypeOf obj.Object Is CommandButton And Left(obj.Name, 5) = "Digit" Then
Set dBtn = New ClDigitalButtons
dBtn.Init obj.Object, ws.[B1]
colButtons.Add dBtn
End If
Next
End Sub
[/vba]в модуле ЭтаКнига[vba]Код
Private Sub Workbook_Open()
hookButtons ActiveSheet
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
hookButtons Sh
End Sub
[/vba]