Private Const sheetTblName As String = "data"
Private Const SetCellsName As String = "$E$5"
Private Const ColumnsName As String = "$B$2"
Private Const ToCell As String = "$A$1"
Sub select_match()
Dim iRow As Integer
Dim iRow2 As Integer
Dim iColumn As Integer
Dim iColumn2 As Integer
Dim iRowCount As Integer
iRowCount = 0
With ActiveSheet
For iRow = .UsedRange.Row To .UsedRange.Row + .UsedRange.Rows.Count
iColumn = Range(SetCellsName).Column
iColumn2 = Range(ColumnsName).Column
shearch_str = Trim(.Cells(iRow, iColumn).Value)
If shearch_str <> "" Then
With Sheets(sheetTblName)
For iRow2 = .UsedRange.Row To .UsedRange.Row + .UsedRange.Rows.Count
ind_str = Trim(.Cells(iRow2, iColumn2).Value)
If shearch_str = ind_str Then
tt = cpyRange(iRowCount, iRow2, .UsedRange.Column, .UsedRange.Column + .UsedRange.Columns.Count)
iRowCount = iRowCount + 1
Exit For
End If
Next
End With
End If
Next
End With
End Sub
Function cpyRange(toRow As Integer, Row As Integer, startColumn As Integer, endColumn As Integer) As String
Dim iColumn As Integer
Dim iColumnCount As Integer
iColumnCount = 0
For iColumn = startColumn To endColumn
ThisWorkbook.Sheets("tmp").Cells(Range(ToCell).Row + toRow, Range(ToCell).Column + iRowCount) = Sheets(sheetTblName).Cells(Row, iColumn)
iRowCount = iRowCount + 1
Next
End Function