AW: Text aus Textbox in Zelle
22.12.2004 21:39:22
Hajo_Zi
Hallo Andreas,
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
' von Peter Haserodt
' nur Buchstaben
Select Case KeyAscii
Case 97 To 122, 65 To 90, 228, 246, 252, 196, 214, 220, 223
Case Else
KeyAscii = 0
MsgBox "Nur Buchstaben", vbExclamation
End Select
End Sub
Private Sub TextBox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
' von Peter Haserodt
' nur Buchstaben (Groß)
Select Case KeyAscii
Case 65 To 90, 196, 214, 220
Case Else
KeyAscii = 0
MsgBox "Nur Großbuchstaben", vbExclamation
End Select
End Sub
Private Sub TextBox8_AfterUpdate()
Range("A1") = CDbl(TextBox8)
End Sub
Private Sub TextBox8_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
' Ansatz VB 6 Buch von Peter Monadjemi
' nur Zahlen, ein Komma und nur 2 Stellen nach Komma
Select Case KeyAscii
Case Asc("0") To Asc("9")
If InStr(TextBox8, ",") <> 0 Then
If Len(TextBox8) - InStr(TextBox8, ",") > 1 Then KeyAscii = 0
End If
Case Asc("."), Asc(",")
If InStr(TextBox8, ",") <> 0 Then
KeyAscii = 0
Else
KeyAscii = Asc(",")
End If
Case Asc(vbBack)
' Eingabe von minus
Case Asc("-")
' If Len(Textbox8) = 0 Then
' If InStr(Textbox8, "-") <> 0 Then
' Else
' KeyAscii = Asc("-")
' End If
' Else
' KeyAscii = 0
' End If
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub Textbox8_Change()
' Eingabe von Minus auch nachträglich
' diese Code ist eine gemeinasme Arbeit von Hajo und
' theonlyrobi (Robert) aus dem Forum
' <a href="http://www.ms-office-forum.net/forum/forumdisplay.php?s=&forumid=29">http://www.ms-office-forum.net/forum/forumdisplay.php?s=&forumid=29</a>
Dim BoWert As Boolean
If InStr(TextBox8, "-") >= 1 And Left(TextBox8, 1) <> "-" Then
TextBox8 = Replace(TextBox8, "-", "")
BoWert = True
ElseIf InStr(TextBox8, "-") = 1 And InStr(2, TextBox8, "-") >= 1 Then
BoWert = True
If Left(TextBox8, 1) = "-" Then
TextBox8 = "-" + Replace(TextBox8, "-", "")
Else
TextBox8 = Replace(TextBox8, "-", "")
End If
End If
If BoWert = True Then MsgBox "Ein Minus darf nur an erster Stelle stehen! Beispiel: -123,45"
End Sub
Bitte keine Mail, Probleme sollten im Forum gelöst werden.
Microsoft MVP für Excel
Das Forum lebt auch von den Rückmeldungen.
Betriebssystem XP Home SP2 und Excel Version 2003 SP1.