Hi,
I have the following Vlookup formula in a cell, which works fine:
=VLOOKUP(J11,'BT Site Directory.xls'!Directory, 2, FALSE)
I need this in a VBA Form, however when I convert it to what I think will work, I get the error "Subscript Out Of Range" on the Vlookup line.
The code is:
Dim Skyline As String
Dim ExchangeName As String
Dim LookupWorkbook As String
Dim LookupRange As String
LookupWorkbook = "BT Site Directory.xls"
LookupRange = "Directory"
Skyline = FrmLookup.TbxSkyline.Value
ExchangeName = Application.VLookup(Skyline, Workbooks(LookupWorkbook).Range(LookupRange), 1, False)
FrmLookup.TbxExchangeName.Value = ExchangeName
I've tried it without passing in variables but have seperated them to check that they are all populating correctly.
Where am I going wrong?!!
Any help would be greatly appreciated.
Regards,
Richard
I have the following Vlookup formula in a cell, which works fine:
=VLOOKUP(J11,'BT Site Directory.xls'!Directory, 2, FALSE)
I need this in a VBA Form, however when I convert it to what I think will work, I get the error "Subscript Out Of Range" on the Vlookup line.
The code is:
Dim Skyline As String
Dim ExchangeName As String
Dim LookupWorkbook As String
Dim LookupRange As String
LookupWorkbook = "BT Site Directory.xls"
LookupRange = "Directory"
Skyline = FrmLookup.TbxSkyline.Value
ExchangeName = Application.VLookup(Skyline, Workbooks(LookupWorkbook).Range(LookupRange), 1, False)
FrmLookup.TbxExchangeName.Value = ExchangeName
I've tried it without passing in variables but have seperated them to check that they are all populating correctly.
Where am I going wrong?!!
Any help would be greatly appreciated.
Regards,
Richard