Zeilen kopieren
12.02.2004 23:10:46
helena
habe kleines Problem, denke ich für Euch Profis
möchte in bestimmten Spalten Begriff suchen und kopieren, CODE ist von CD von
HANS, er funktioniert kann aber SUCHBEREICH nicht einschränken zB nur in A:A
oder A:C ???? sehe es leider nicht
Sub SearchNames()
Dim rng As Range, rngSource As Range, rngStart As Range
Dim varInput As Variant
Dim iRow As Integer
varInput = Application.InputBox( _
prompt:="Geben Sie bitte den Namen ein:", _
Title:="Zeilen kopieren", _
Default:="?", _
Left:=263, _
Top:=169, _
Type:=2)
If varInput = False Then Exit Sub
Set rng = ActiveSheet.Columns("A:B").Find( _
what:=varInput, lookat:=xlWhole, LookIn:=xlValues)
If rng Is Nothing Then
Beep
MsgBox "Suchbegriff nicht gefunden!"
Exit Sub
End If
Set rngStart = rng
Set rngSource = rng.EntireRow
Do
Set rng = Cells.FindNext(After:=rng)
If rng.Address = rngStart.Address Then Exit Do
Set rngSource = Application.Union(rngSource, rng.EntireRow)
Loop
With Worksheets("Tabelle2")
iRow = .Cells(Rows.Count, 1).End(xlUp).Row
If iRow = 1 Then iRow = 15 Else iRow = iRow + 1
rngSource.Copy .Cells(iRow, 1)
'.Columns.AutoFit
End With
End Sub
kopieren sonst funktioniert
DANKE
gruss helena