|
なお、Sheet2のA列 IPアドレスがたくさんあるときは
Sheet1の対応表を Dictionaryオブジェクトに記憶しておくと
何度もMatch検索しなくて済むので、効率よくなります
Sub IP_Hostname()
Dim dic As Object
Dim c As Range
Set dic = CreateObject("Scripting.Dictionary")
With Worksheets(1)
For Each c In .Range("E2", .Cells(.Rows.Count, "E").End(xlUp))
dic(c.Text) = c(1, 0).Text 'Key: IPアドレス 値:ホスト名
Next
End With
With Worksheets(2)
For Each c In .Range("A2", .Cells(.Rows.Count, 1).End(xlUp))
If dic.Exists(c.Value) Then
c(1, 2).Value = Replace(c(1, 2), "●●", dic(c.Value))
End If
Next
End With
Set dic = Nothing
End Sub
|
|