Zelle bei Eingabe per Button formatieren
09.03.2004 15:38:15
Mathias
mit folgendem Code lese ich die Textbox aus und übernehme die Inhalte in die Tabelle:
Private Sub Ok_CommandButton_Click()
Dim Found As Range
Dim LoLetzte As Long
Dim sSearch As String
sSearch = Ia_TextBox.Text
If sSearch = "" Then Exit Sub
LoLetzte = IIf(IsEmpty(Range("A65536")), Range("A65536").End(xlUp).Row, 65536)
Set Found = Range("A1:A" & LoLetzte).Find(sSearch, Range("A" & LoLetzte), , xlPart, , xlNext)
' hier wird der Begriff gesucht und falls nicht gefunden wird sub verlasssen
' If Found Is Nothing Then Exit Sub 'falls nicht gefunden wird sub verlassen
If Found Is Nothing Then
' Range(Found.Address).Select
With Tabelle1
' der interne Name der Tabelle ist Tabelle1, es ist nicht das gemeint was auf dem Register steht
LoLetzte = IIf(IsEmpty(.Range("A65536")), .Range("A65536").End(xlUp).Row, 65536)
If Loletze = 65536 Then Exit Sub ' keine Zeile mehr frei
LoLetzte = LoLetzte + 1
.Cells(LoLetzte, 1) = Ia_TextBox.Text
.Cells(LoLetzte, 2) = Ak_TextBox.Text
.Cells(LoLetzte, 3) = Ma_TextBox.Text
.Cells(LoLetzte, 4) = Beschreibung_TextBox.Text
.Cells(LoLetzte, 5) = Beginn_TextBox.Text
.Cells(LoLetzte, 6) = Ende_TextBox.Text
If ZoneJa_CheckBox Then Cells(LoLetzte, 7) = "X"
If ZoneNein_CheckBox Then Cells(LoLetzte, 8) = "X"
If Not ZoneNein_CheckBox Then Cells(LoLetzte, 8) = ""
If Not ZoneJa_CheckBox Then Cells(LoLetzte, 7) = ""
End With
End If
End Sub
nun möchte ich die jeweiligen Zellen bei Eingabe per button formatieren. Wie kann ich das in den Code einbinden? Oder welche anderen Möglichkeiten mittels vba stehen mir zur Verfügung?
Gruss Mathias