WorksheetFunctionでVlookup関数を利用

 

Sub test()

' WorksheetFunctionでVlookup関数を利用

      Dim xlMaster As Range    '検索対象マスターシート
      Dim key        '検索キー
      Dim myRes  ' 検索結果

      
      
      Set xlMaster = Sheets("Master").Range("A:B")


      key = Range("A2").Value

      On Error Resume Next

      myRes = WorksheetFunction.VLookup(key, xlMaster, 2, False)
      On Error GoTo 0

      Range("B2").Value = myRes

 

 


End Sub

 

 

 

― ― ― ― ― ― ― ― ― ― → Excel VBA基礎入門もくじ へ戻る 

 

参考記事