|
'-------------------------------
Sub cmdSearch_Click()
'-------------------------------
Dim searchValue As Variant: searchValue = Range("B3").Value
' 찾는 값 없으면 종료
If searchValue = "" Then Exit Sub
Dim sourceData As Range
Set sourceData = Worksheets("Sheet2").Range("A1").CurrentRegion
Set sourceData = sourceData.Offset(1).Resize(sourceData.Rows.Count - 1)
Dim xRow As Range
Dim tRng As Range: Set tRng = Range("A6")
Dim iRow As Long: iRow = 1
Application.ScreenUpdating = False
'-------------------------------------
For Each xRow In sourceData.Rows
'-------------------------------------
' 명칭이 같으면
If xRow.Cells(1, 1).Value = searchValue Then
' 기존 자료 지우기
If iRow = 1 Then Range("A6:H100").ClearContents: iRow = iRow + 1
' 데이타 삽입하기
tRng.Resize(1, 4).Value = _
Array(xRow.Cells(2).Value, xRow.Cells(3).Value, xRow.Cells(4).Value, xRow.Cells(7).Value)
' 붙일 위치 다음 행으로 이동
Set tRng = tRng.Offset(1)
End If
Next
Application.ScreenUpdating = True
End Sub
|
|