I have quite a big excel that contains orders information. My goal is to find in the "customer name column" (H:H) the orders that are for commercial addresses based on key words and then copy the rows, where the values are found, to a new sheet.
Got a list of key words but since I do not know how to make use of it in VBA, I just have a code that will repeat the search based on each word as long as I copy paste the code and write a new value/word to be searched for. Once a key word is identified, the whole row will be copied in sheet 3. Sheet 1 contains the raw data and sheet 2 contains the list of words for each I do not know how to run a code that will include them in the search without me writing them 1 by 1 each time.
Sub Commercial()
Dim cell As Range
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "gmbh") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "studio") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "solution") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "büro") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "consult") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "firma") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "system") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "computer") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "department") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "bmw") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "bank") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "anwalt") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "finance") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "filiale") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "software") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "ihk") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "international") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "embassy") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "konsulat") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "mobil") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "Dr.") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "praxis") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "partner") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "market") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
With Sheets(1)
For Each cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If InStr(cell.Value, "indust") > 0 Then
.Rows(cell.Row).Copy Destination:=Sheets(3).Rows(cell.Row)
End If
Next cell
End With
End Sub