|
▼vba初心者 さん:
>BOOK1のV列とBOOK2のA列を比較し、一致するならBOOK1のU列に
>1699 と数字を入れたく思います
>一致しなければ何もしません
ある列とある列の比較なら VLOOKUP より MATCH でしょうね
Sub Try1()
Dim r As Range, u As Range
Dim a As Range, aAddress As String
With Workbooks("Book1.xls").Worksheets(1)
Set r = .Range("V2", .Cells(.Rows.Count, "V").End(xlUp))
Set u = r.Offset(, -1)
End With
With Workbooks("Book2.xls").Worksheets(1)
Set a = .Range("A2", .Cells(.Rows.Count, "A").End(xlUp))
aAddress = a.Address(External:=True)
End With
'U列に数式(V列と Book2のA列と照合して、一致したら 1699、なければ "" )
u.Formula = "=IF(ISNUMBER(MATCH(V2," & aAddress & ",0)),1699,"""")"
End Sub
|
|