AW: Suchen und Drucken
12.10.2016 11:19:02
Werner
Hallo Thomas,
teste mal:
Public Sub test()
Dim varSuche As Variant
Dim rngFund As Range
Anfang:
varSuche = Application.InputBox(prompt:="Bitte eine Ganzzahl eingeben:", Type:=2)
If varSuche = False Then Exit Sub
If IsNumeric(varSuche) Then
'### Tabellenblatt an deine Bedürfnisse anpassen ###
Set rngFund = Sheets("Tabelle1").Columns(3).Find(What:=varSuche, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)
If Not rngFund Is Nothing Then
'### Tabellenblatt an deine Bedürfnisse anpassen ###
With Sheets("Tabelle1")
Application.ScreenUpdating = False
.Columns(3).Hidden = True
.Range(.Cells(rngFund.Row, 1), .Cells(rngFund.Row, 5)).PrintPreview
.Columns(3).Hidden = False
Application.ScreenUpdating = True
End With
Else
MsgBox "Suchbegriff " & varSuche & " nicht gefunden."
End If
ElseIf Not IsNumeric(varSuche) And varSuche "" Then
MsgBox "Nur Zahlen erlaubt."
GoTo Anfang
End If
End Sub
Gruß Werner