UserForm - Zahlen - Komma -Tabellenblatt!

Frage: Wie kann man über eine UserForm Zahlen und Komma in Zellen eingeben? Die Windowsinterne Bildschirmtastatur (OSK) soll nicht verwendet werden. So:

UserForm - Zahlen - Komma -Tabellenblatt...[ZIP, 60 KB]

'Code in "DieseArbeitsmappe":

Option Explicit
Private Sub Workbook_Open()
UserForm1.Show 0
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call Terminate_Class
End Sub

'Code in ein Modul:

Option Explicit
Private objButton() As clsButton
Public Sub Terminate_Class()
Dim lngIndex As Long
If IsArray(objButton) Then
For lngIndex = LBound(objButton) To UBound(objButton)
Set objButton(lngIndex) = Nothing
Next
End If
Erase objButton
End Sub

'Code in "UserForm1":

Option Explicit
Private objButton() As clsButton
Private Sub UserForm_Activate()
Dim objControl As Control
Dim lngCounter As Long
For Each objControl In Controls
If TypeOf objControl Is MSForms.CommandButton Then
ReDim Preserve objButton(0 To lngCounter)
Set objButton(lngCounter) = New clsButton
Set objButton(lngCounter).SetButton = objControl
lngCounter = lngCounter + 1
End If
Next objControl
End Sub
Private Sub Label1_Click()
Unload Me
End Sub

'Code in einem Klassenmodul mit Namen "clsButton":

Option Explicit
Private WithEvents mobjButton As MSForms.CommandButton
Friend Property Set SetButton(objButton As MSForms.CommandButton)
Set mobjButton = objButton
End Property
Private Sub mobjButton_Click()
With ActiveSheet.Cells(ActiveCell.Row, ActiveCell.Column)
.Value = .Value & mobjButton.Caption
End With
If Not mobjButton.Caption = "," Then
ActiveSheet.Columns(ActiveCell.Column).TextToColumns
End If
End Sub

Kommentare

Beliebte Posts aus diesem Blog

Formeln - auch Array - per VBA eintragen...

Alle Dateien eines Ordners - Optional mit Unterordner

Excel -> Word in Textmarken (Bookmarks)...