Code für Userform 1:
Private Sub Störung_suchen_Click()
Dim rngSuchErgebnisGesamt As Range
Dim rngSuchErgebnisEinzel As Range
Dim Suchtext As String
Dim sh As Worksheet
Suchtext = TextBox3
Set sh = ActiveSheet
Set rngSuchErgebnisEinzel = sh.Cells.Find(what:=Suchtext, lookat:=xlPart, LookIn:=xlValues)
If rngSuchErgebnisEinzel Is Nothing Then
MsgBox "Der Suchbegriff konnte nicht gefunden werden"
Else
Set rngSuchErgebnisGesamt = rngSuchErgebnisEinzel
Do
Set rngSuchErgebnisEinzel = sh.Cells.FindNext(after:=rngSuchErgebnisEinzel)
If Intersect(rngSuchErgebnisEinzel, rngSuchErgebnisGesamt) Is Nothing Then
Set rngSuchErgebnisGesamt = Union(rngSuchErgebnisEinzel, rngSuchErgebnisGesamt)
Else
Exit Do
End If
Loop
rngSuchErgebnisGesamt.Interior.ColorIndex = 3
Range("A2").Select
ActiveCell.FormulaR1C1 = "=Versuch_3"
Range("A3").Select
End If
Z = Sheets(1).UsedRange.Rows.Count
For i = 1 To Z
If Cells(i, 1) = 3 Then
temp = 1
Exit For
End If
Next
If temp = 1 Then
Unload Me
zeile = i
UserForm2.Show
Else
MsgBox " Fehler oder Störung nicht vorhanden ", vbExclamation
TextBox3 = ""
End If
End Sub
bei der zweiten Userform sieht er dann so aus:Private Sub UserForm_Initialize()
TextBox1 = Cells(zeile, 2)
TextBox2 = Cells(zeile, 3)
TextBox3 = Cells(zeile, 4)
End Sub