I have a VBA Vlookup on a user form from which I would like the data to come from an excel file saved on the intranet.
When I try the VLookup
which takes the data on the intranet, it works as follows:
=VLOOKUP(I6,'https://intranet.private.private.uk/folder1/folder2/folder3/Documents/[Contract database.xlsm]AvailableContracts'!$H$9:$L$108,2,FALSE)
I would like to incorporate that link into the VBA below without getting an error message:
Private Sub ContractsList_AfterUpdate()
If WorksheetFunction.CountIf(Sheet2.Range("A:A"), Me.ContractsList.Value) = 0 Then
MsgBox "This contract is not on the list"
Me.ContractsList.Value = ""
Exit Sub
End If
'Lookup values based on first control
With Me
.TextBox1 = Application.WorksheetFunction.VLookup(Me.ContractsList, Sheet2.Range("A5:E72"), 2, 0)
End With
End Sub
The line that kicks the error is:
.TextBox1 = Application.WorksheetFunction.VLookup(Me.ContractsList, Sheet2.Range("A5:E72"), 2, 0)
when I change Sheet2.Range("A5:E72")
with the intranet link above in the excel VLookup
formula.