AW: UF OptionButton auswählen
27.12.2014 07:41:54
Crazy
Hallo Erwin
dann würde ich es so machen
ins Tabellenblatt
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngBereich As Range
Set rngBereich = Range("V28, V38")
If Not Intersect(Target, rngBereich) Is Nothing Then
BVG_Grundrenten.Show
End If
End Sub
damit wird die Userform nur in den Zellen V28 und V38 gestartet
das hier gehört jetzt in die Userform
hiermit wird die Eingabe in Textbox1 auf Zahlen und das Komma beschränkt
Private Sub Textbox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57, 44
Case Else:
KeyAscii = 0
MsgBox "Es sind nur Ziffern erlaubt!", vbInformation, "Hinweis"
End Select
End Sub
hier wird überprüft ob der Textboxwert zwischen 0 und 1000 liegt
Private Sub CommandButton1_Click() 'Button freie Betragseingabe übernehmen
If CDbl(TextBox1.Value) 1000 Then
MsgBox "nur Beträge zwischen 0 und 1000 erlaubt"
Exit Sub
Else
ActiveCell.Value = CDbl(TextBox1.Value)
TextBox1.Value = ""
Unload Me
End If
End Sub
hier wird abgefragt welcher Optionbutton aktiv ist und der Wert (Caption) in eine Variable übergeben
so brauchst du keine 12 If-Abfragen welcher Optionbutton aktiv ist
die Variable wird dann in die aktive Zelle (V28 oder V38) geschrieben
Private Sub CommandButton3_Click()
Dim myControl As Control
Dim dblWert As Double
For Each myControl In Me.Controls
If TypeName(myControl) = "OptionButton" Then
If myControl.Value = True Then
dblWert = myControl.Caption
End If
End If
Next
ActiveCell.Value = dblWert
Unload Me 'UF schließen
End Sub
MfG Tom