@ Радж, я не уверен, что ты имеешь в виду, но я пытаюсь создать код.
Лист 1
![enter image description here](https://i.stack.imgur.com/icekM.jpg)
- Структура включает в себя поисковую систему (желтая область) и результаты)
- Вы просто импортируете данные в желтые поля
- , где выполняется код, стирая результаты, чтобы вывести новые.
Лист 2
![enter image description here](https://i.stack.imgur.com/rEj9H.jpg)
Структура (включая базу данных)
Попробуйте:
Option Explicit
Sub Test()
Dim LastRow2 As Long
Dim i As Long
Dim Mat_Cat_Loc As String
Dim LastRow1 As Long
With Sheet1
If .Range("B2").Value = "" Or .Range("B3").Value = "" Or .Range("B4").Value = "" Then '<= if some search part missing end sub
Exit Sub
End If
Mat_Cat_Loc = .Range("B2").Value & .Range("B3").Value & .Range("B4").Value ' <= Create Mat_Cat_Loc for the search product
LastRow1 = .Range("A" & Rows.Count).End(xlUp).Row
.Range("A8:D" & LastRow1).Clear '<= Clear range from the previous search
End With
With Sheet2
LastRow2 = .Range("A" & Rows.Count).End(xlUp).Row
For i = 3 To LastRow2 ' <= Loop in Sheet2 and if Mat_Cat_Loc (From the search) does not match Mat_Cat_Loc (From the data does not copy the line to Sheet1 Rsult Table)
If (.Range("D" & i).Value <> Mat_Cat_Loc) And (.Range("C" & i).Value) <> Sheet1.Range("B4").Value Then
With Sheet1
LastRow1 = .Range("A" & Rows.Count).End(xlUp).Row
.Range("A" & LastRow1 + 1).Value = Sheet2.Range("A" & i).Value
.Range("B" & LastRow1 + 1).Value = Sheet2.Range("B" & i).Value
.Range("C" & LastRow1 + 1).Value = Sheet2.Range("C" & i).Value
.Range("D" & LastRow1 + 1).Value = Sheet2.Range("D" & i).Value
End With
End If
Next i
End With
End Sub