0
아래 에서처럼 한 시트에서 다른 시트로 데이터를 복사하는 코드가 있지만 조회 부분이 작동하지 않습니다. 내가이 검색 기능을 사용하지 않는 경우 다음 코드는 게시물에 따르면 좋은vlookup 및 if 조건 복사 데이터 vba
Sub CopyRows()
Dim Rng As Range
Dim Rng2 As Range
Dim Cl As Range
Dim str As String
Dim RowUpdCrnt As Long
Set UsedRange = Sheets("Jan").Range("b5:bk81")
Set Rng = Sheets("Jan").UsedRange 'the range to search ie the used range
Set Rng2 = Sheets("Feb").Range("I5:AK5")
str = "WRK." 'string to look for
Sheets("Feb").Range("B5:B81").Value = ""
RowUpdCrnt = 5
' In my test data, the "WRK."s are in column AN. This For-Each only selects column AN.
' I assume all my "WRK."s are in a single column. Replace "B" by the appropriate
' column letter for your data.
For Each Cl In Rng.Columns("AN").Rows
If Cl.Text = str Then
'if the cell contains the correct value copy it to next empty row on sheet 2 & delete the row
VLookup(Cl.EntireRow.Range("b1"), Sheets("Master").Range("H7:H200"), 1, 0).Copy
Sheets("Feb").Cells(RowUpdCrnt, 2).PasteSpecial xlPasteValues
RowUpdCrnt = RowUpdCrnt + 1
End If
Next Cl
Application.CutCopyMode = False
End Sub
시도'대신 Application.VLookup' –