IfError function using vlookup in VBA
<p>I am trying to use a vlookup function to search for a value in multiple worksheets that are in a separate workbook.</p>

<p>I am trying to use the IfError function with the vlookup but I am not formatting it correctly. </p>

<pre><code>Sub CommandButton1_Click()

    Dim item As String
    item = 8

    Dim brange, rbrange, jrange, cdrange, cprange As range
    Set brange = Workbooks("Library_Database.xlsx")_
                 .Worksheets("BOOKS").range("A2:H51")
    Set rbrange = Workbooks("Library_Database.xlsx")_
                  .Worksheets("REFERENCE BOOKS").range("A2:H51")
    Set jrange = Workbooks("Library_Database.xlsx")_
                 .Worksheets("JOURNALS").range("A2:H51")
    Set cdrange = Workbooks("Library_Database.xlsx")_
                  .Worksheets("CDS").range("A2:H51")
    Set cprange = Workbooks("Library_Database.xlsx")_
                  .Worksheets("CONFERENCE PROCEEDINGS").range("A2:H51")

    Dim title As String
    title = IfError(VLookup(item, brange, 2, False), _
            IfError(VLookup(item, rbrange, 2, False), _
            IfError(VLookup(item, jrange, 2, False), _
            IfError(VLookup(item, cdrange, 2, False), _
            IfError(VLookup(item, cprange, 2, False), "")))))

End Sub
</code></pre>