は、私は良い動作するコードを持っているが、私はシートのセルB5のコピーデータ
値としていくつかの変更をしたい場合は、「2月」の範囲内のセルのいずれかが、どれも空白とSheets("Jan").Range("I5:AM81")
ない場合If sheets("Feb").Range("I5:AK81)<>""
(範囲内のセルのいずれかが "TRF"と等しくない場合は、範囲Sheets("master").Range("H7:Q200"),1,0)
のシート "Jan"のセルセルB5をコピーして、シート "Feb"のセルB5に貼り付けます。
シートfebの範囲B5:B81の最後の空白欄に移動し、シートの列Oの日付(「マスター」)がある場合は範囲( "H7:q200")は現在の現在の月年に適切なセルbをコピーする電子レンジやシートの最後の空のセルに貼り付ける「2月」の範囲B5:B81ので、以下
には、これは巣に必要なあなたの第二の基準を許可し、そしてべきではないコード
Option Explicit
Sub CopyRows()
Dim Cl As Range
Dim str As String
Dim RowUpdCrnt As Long
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.
With Sheets("Jan")
' loop until last row with data in Column AN (and not the entire column) to save time
For Each Cl In .Range("AN1:AN" & .Cells(.Rows.Count, "AN").End(xlUp).Row)
If Cl.Value Like str And Sheets("Feb").Range(Cl.Address).Value <> "" Then
'if the cell contains the correct value copy it to next empty row on sheet 2 & delete the row
If Not IsError(Application.Vlookup(.Range("B" & Cl.Row).Value, Sheets("Master").Range("H7:H200"), 1, 0)) Then ' <-- verify the VLookup was successful
Sheets("Feb").Range("B" & RowUpdCrnt).Value = Application.Vlookup(.Range("B" & Cl.Row).Value, Sheets("Master").Range("H7:H200"), 1, 0)
RowUpdCrnt = RowUpdCrnt + 1
End If
End If
Next Cl
End With
Application.CutCopyMode = False
End Sub