Gruppe
Dialog
Problem
Wie kann ich Daten aus einem Tabellenblatt Gruppenweise in TextBoxes einer UserForm ein- und auf Schaltflächendruck in das Tabellenblatt wieder aulesen, wobei die Strings wieder aufgeteilt werden müssen?
ClassModule: frmTexte
Private Sub cmdAuslesen_Click()
Dim iCells As Integer, iColumns As Integer, iC As Integer
Dim sTxt As String
iC = 1
If Controls("TextBox1").Text = "" Then
Beep
MsgBox "Sie müssen zuerst die Drehfeldauswahl treffen!"
Exit Sub
End If
For iCells = 1 To 4
sTxt = Controls("TextBox" & iCells).Text
For iColumns = 1 To 4
If iColumns < 4 Then
Cells(12, iC) = Left(sTxt, InStr(sTxt, vbLf) - 2)
sTxt = Right(sTxt, Len(sTxt) - InStr(sTxt, vbLf))
iC = iC + 1
Else
Cells(12, iC) = sTxt
iC = iC + 1
End If
Next iColumns
Next iCells
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub drfAuswahl_Change()
Dim iCells As Integer, iColumns As Integer
Dim iR As Integer, iC As Integer
Dim sTxt As String
iR = drfAuswahl.Value
iC = 1
For iCells = 1 To 4
For iColumns = 1 To 4
sTxt = sTxt & Cells(iR, iC) & vbLf
iC = iC + 1
Next iColumns
sTxt = Left(sTxt, Len(sTxt) - 1)
Controls("TextBox" & iCells) = sTxt
sTxt = ""
Next iCells
End Sub
StandardModule: basMain
Sub CallForm()
frmTexte.Show
End Sub