Find NExt ohne active cell
26.06.2013 15:03:56
JACKD
Ich hab eine Userform mit
1 Textbox zur eingabe
5 textboxen zur ausgabe
sowie 2 Buttons (vorwärts und rückwärts suchen)
Bisher hab ich das
so gelöst
(Bei eingabe in Textbox1 fängt er an mit suchen und ergänzt das mit jedem weiteren Buchstaben)
jetzt ist es so dass ich dass als addin implementieren möchte die Tabelle ist also im Hintergrund
Und kann sie ja jetzt nicht mehr mit activecell ansprechen
wie kann ich dass denn umgehen?
Private Sub TextBox1_Change()
With tabNC.Columns(3)
If .Find(khspez.TextBox1.Value) Is Nothing Then Exit Sub
.Find (khspez.TextBox1.Value)
raumdef = ActiveCell.Value 'Raumbezeichnung
raumdef1 = ActiveCell.Offset(0, -2).Value 'Raumcode
If .Cells.FindNext(after:=ActiveCell) Is Nothing Then Exit Sub
.Cells.FindNext(after:=ActiveCell).Select
raumdef2 = ActiveCell.Value 'Raumbezeichnung
raumdef3 = ActiveCell.Offset(0, -2).Value 'Raumcode
If .Cells.FindNext(after:=ActiveCell) Is Nothing Then Exit Sub
.Cells.FindNext(after:=ActiveCell).Select
raumdef4 = ActiveCell.Value 'Raumbezeichnung
raumdef5 = ActiveCell.Offset(0, -2).Value 'Raumcode
If .Cells.FindNext(after:=ActiveCell) Is Nothing Then Exit Sub
.Cells.FindNext(after:=ActiveCell).Select
raumdef6 = ActiveCell.Value 'Raumbezeichnung
raumdef7 = ActiveCell.Offset(0, -2).Value 'Raumcode
If .Cells.FindNext(after:=ActiveCell) Is Nothing Then Exit Sub
.Cells.FindNext(after:=ActiveCell).Select
raumdef8 = ActiveCell.Value 'Raumbezeichnung
raumdef9 = ActiveCell.Offset(0, -2).Value 'Raumcode
If .Cells.FindNext(after:=ActiveCell) Is Nothing Then Exit Sub
.Cells.FindNext(after:=ActiveCell).Select
raumdef10 = ActiveCell.Value 'Raumbezeichnung
raumdef11 = ActiveCell.Offset(0, -2).Value 'Raumcode
End With
khspez.TextBox3.Value = raumdef
khspez.TextBox14.Value = raumdef1
khspez.TextBox5.Value = raumdef2
khspez.TextBox15.Value = raumdef3
khspez.TextBox7.Value = raumdef4
khspez.TextBox16.Value = raumdef5
khspez.TextBox9.Value = raumdef6
khspez.TextBox17.Value = raumdef7
khspez.TextBox11.Value = raumdef8
khspez.TextBox18.Value = raumdef9
khspez.TextBox13.Value = raumdef10
khspez.TextBox19.Value = raumdef11
End Sub
Grüße