を使用している間、私は、彼らが同じIDを持っている場合、私はlastweekのすべての詳細を取得したいと思い、シートの両方の列Bを比較したい2枚、理性とLastweekエラーVLOOKUP
を持っています理由シートの第33〜50欄のシート。
私は出力を得ることができます、問題は、例えばです。私の最後の週の欄の34欄にデータがあれば、それは理由票の33欄に入力されています。
私はこれをどのように克服することができます誰かが助けることができます。
Sub lookupUpdate()
Dim BWlRow As Long, CWlRow As Long, i As Long
Dim sformula As String
Dim wsBW As Worksheet, wsCW As Worksheet
Set wsBW = Sheets("Reason"): Set wsCW = Sheets("Lastweek")
BWlRow = wsBW.Cells(wsBW.Rows.count, "A").End(xlUp).Row
CWlRow = wsCW.Cells(wsCW.Rows.count, "A").End(xlUp).Row
For i = 33 To 50 '~~> Col AD to AU
sformula = "=IF(IFERROR(VLOOKUP($B2,Lastweek!$B$2:$AZ" & _
CWlRow & _
"," & _
i & _
",FALSE),""0"")=0,"" "",IFERROR(VLOOKUP($B2,Lastweek!$B$2:$AZ" & _
CWlRow & _
"," & _
i & _
",FALSE),""""))"
With wsBW
With .Range(.Cells(2, i), .Cells(BWlRow, i))
.Formula = sformula
.Value = .Value
End With
End With
Next i
End Sub