
Originally Posted by
T-J
If using the Worksheets Collection, use a Select Case to check the worksheet name:
For Each ws In ThisWorkbook.Worksheets
Select Case ws.Name
Case "Sheet1", "Sheet3", "Sheet4", "Sheet5" 'sheets to search
Set rngSearch = ws.Range("A1:E2000")
Set wSht = Worksheets("Sheet2") 'results sheet
With rngSearch
'search code here
End With
End Select
Next
hey T-J,
the code that u gave me works fine, but now a new problem has raised...
the problem by your code is that, it pastes the info from sheet1, but then it pastes the new info from sheet2 OVER infos from sheet1...
tried manupilating it myself, but the inputbox keeps coming out, and i have to enter what i wanted to find twice...
here's the list of my actual VBA codes that i have...
Private Sub CommandButton1_Click()
FindMe
End Sub
Private Sub CommandButton2_Click()
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A1").Select
End Sub
Sub FindMe()
Dim intS As Integer
Dim rngC As Range
Dim strToFind As String, FirstAddress As String
Dim wSht As Worksheet
Dim rngSearch As Range
Application.ScreenUpdating = False
intS = 2
Set rngSearch = Worksheets("Tabelle1").Range("A1:IV65535")
Set wSht = Worksheets("Tabelle3")
strToFind = InputBox("Geben Sie den PLZ oder NE Kennung")
Do While strToFind <> ""
With rngSearch
Set rngC = .Find(what:=strToFind, LookAt:=xlPart)
If Not rngC Is Nothing Then
FirstAddress = rngC.Address
Do
rngC.EntireRow.Copy wSht.Cells(intS, 1)
intS = intS + 1
Set rngC = .FindNext(rngC)
Loop While Not rngC Is Nothing And rngC.Address <> FirstAddress
End If
End With
strToFind = InputBox("Klicken Sie bitte Abbrechen")
Loop
Application.ScreenUpdating = True
Set rngSearch = Nothing
Set wSht = Nothing
Set rngC = Nothing
Set rngSearch = Worksheets("Tabelle2").Range("A1:IV65535")
Set wSht = Worksheets("Tabelle3")
strToFind = InputBox("Geben Sie den PLZ oder NE Kennung")
Do While strToFind <> ""
With rngSearch
Set rngC = .Find(what:=strToFind, LookAt:=xlPart)
If Not rngC Is Nothing Then
FirstAddress = rngC.Address
Do
rngC.EntireRow.Copy wSht.Cells(intS, 1)
intS = intS + 1
Set rngC = .FindNext(rngC)
Loop While Not rngC Is Nothing And rngC.Address <> FirstAddress
End If
End With
strToFind = InputBox("Klicken Sie bitte Abbrechen")
Loop
Application.ScreenUpdating = True
Set rngSearch = Nothing
Set wSht = Nothing
Set rngC = Nothing
End Sub
because i don't actually know how to do it, i HAD to re-write the codes again(the search-copy-paste function)i know there's an easier way....just can't get to it
cheers
eddy
Bookmarks