ich möchte gern in einer Spalte (D) eine Zahl bzw. Wert per Textbox suchen und dann sollte die Zelle
aktiviert bzw. sichtbar sein.
Würde mich um Unterstützung freuen,
mfg sigrid
Sub Unit()
Dim TB As Variant
Dim X As Variant
Worksheets("Tabelle1").Range("D1:D5").Formula = "=Row()+0.10"
Worksheets("Tabelle1").TextBox1.Value = "5,10"
TB = Worksheets("Tabelle1").TextBox1.Value
If IsNumeric(TB) Then TB = CDbl(TB)
X = Application.Match(TB, Worksheets("Tabelle1").Range("D:D"), 0)
If IsError(X) Then
MsgBox TB & " wurde nicht gefunden!"
Else
Application.Goto Worksheets("Tabelle1").Range("D:D").Cells(X)
End If
End Sub
Gruß Gerd
Sub Suchen()
Dim rngSuche As Range
If Tabelle1.TextBox1 > "" Then
If IsNumeric(Tabelle1.TextBox1) Then
Set rngSuche = Columns(4).Find(CDbl(Tabelle1.TextBox1), lookat:=xlWhole)
Else
Set rngSuche = Columns(4).Find(Tabelle1.TextBox1, lookat:=xlWhole)
End If
If Not rngSuche Is Nothing Then Application.Goto reference:=rngSuche
End If
End Sub
Den Codenamen der Tabelle - im Beispiel Tabelle1 - musst du natürlich anpassen.
Sub Suchen()
Dim rngSuche As Range
With Worksheets("Lager_Liste")
If .TextBox2 > "" Then
If IsNumeric(.TextBox2) Then
Set rngSuche = .Columns(4).Find(CDbl(.TextBox2), lookat:=xlWhole)
Else
Set rngSuche = .Columns(4).Find(.TextBox2, lookat:=xlWhole)
End If
If Not rngSuche Is Nothing Then
Application.Goto reference:=rngSuche, Scroll:=True
.Range(.Cells(rngSuche.Row, 1), .Cells(rngSuche.Row, 12)).Select
End If
End If
End With
End Sub
Bis späterSub Suchen() Dim rngSuche As Range, rw As Long, sp As Integer With Worksheets("Lager_Liste") If .TextBox2 > "" Then If IsNumeric(.TextBox2) Then Set rngSuche = .Columns(4).Find(CDbl(.TextBox2), lookat:=xlWhole) Else Set rngSuche = .Columns(4).Find(.TextBox2, lookat:=xlWhole) End If If Not rngSuche Is Nothing Then rw = rngSuche.Row 'aktive Zeile sp = rngSuche.Column 'aktive Saplte Application.Goto reference:=rngSuche, Scroll:=True .Range(.Cells(rngSuche.Row, 1), .Cells(rngSuche.Row, 12)).Select 'Bildschirm über ScrollRow + ScrollColumn einstellen ActiveWindow.ScrollRow = rw - 10 ActiveWindow.ScrollColumn = sp - 1 End If End If End With End Sub
set rngSuche = ...Find(...) ' das habt ihr ja schon
if not rngSuche is Nothing then
application.Goto rngSuche
with ActiveWindow
.ScrollRow = Worksheetfunction.Max(1, rngSuche.row - .VisibleRange.Rows.count / 2 + 1)
.ScrollColumn = Worksheetfunction.Max(1, rngSuche.column - .VisibleRange.Columns.count / 2 +1)
end with
end if
Gruß DanielPrivate Sub TextBox2_Change() Dim TB As Variant Dim X As Variant Dim rngSuche As Range If Worksheets("Lager).TextBox2 > "" Then If IsNumeric(Worksheets("Lager").TextBox2) Then Set rngSuche = Columns(2).Find(CDbl(Worksheets("Lager").TextBox2), lookat:=xlWhole) Else Set rngSuche = Columns(2).Find(Worksheets("Lager").TextBox2, lookat:=xlWhole) End If If Not rngSuche Is Nothing Then Application.Goto rngSuche With ActiveWindow Range(Cells(rngSuche.Row, 2), Cells(rngSuche.Row, 11)).Select .ScrollRow = WorksheetFunction.Max(1, rngSuche.Row - .VisibleRange.Rows.Count / 2 + 1) .ScrollColumn = WorksheetFunction.Max(1, rngSuche.Column - .VisibleRange.Columns.Count / 2 + 1) End With End If End If End Subklappt soweit aber nur ein kleines Problem: