ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VLookup (https://www.excelbanter.com/excel-programming/375333-vlookup.html)

BigMac

VLookup
 
Hi, I'm totally new to VBA, so I do need some help.

Been trying to do a Vlookup function on VBA, but I keep getting Error
1001: Application-defined or object-defined error. Here's my code:



Private Sub cmdFinduser_Click()

Dim MyRange As Long
Dim colNumber As Long

MyRange = Sheets("MemberList").Range("B:0").Text

txtName.Text = Application.WorksheetFunction.VLookup(txtFOM.Text,
MyRange, 4, False)

End Sub


Thanks for the help


Nick Hodge

VLookup
 
I don't know what txtFOM is, but presuming this is correct, you have a typo
in the range("B:O") you have a zero instead of a O

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England

HIS
www.nickhodge.co.uk

"BigMac" wrote in message
ups.com...
Hi, I'm totally new to VBA, so I do need some help.

Been trying to do a Vlookup function on VBA, but I keep getting Error
1001: Application-defined or object-defined error. Here's my code:



Private Sub cmdFinduser_Click()

Dim MyRange As Long
Dim colNumber As Long

MyRange = Sheets("MemberList").Range("B:0").Text

txtName.Text = Application.WorksheetFunction.VLookup(txtFOM.Text,
MyRange, 4, False)

End Sub


Thanks for the help




BigMac

VLookup
 
Goodness, foolish me. Thank you so much!

Another thing I realised that I have to set MyRange as Variant, not as
Long

Cheers!

-Mac

Nick Hodge wrote:
I don't know what txtFOM is, but presuming this is correct, you have a typo
in the range("B:O") you have a zero instead of a O

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England

HIS
www.nickhodge.co.uk

"BigMac" wrote in message
ups.com...
Hi, I'm totally new to VBA, so I do need some help.

Been trying to do a Vlookup function on VBA, but I keep getting Error
1001: Application-defined or object-defined error. Here's my code:



Private Sub cmdFinduser_Click()

Dim MyRange As Long
Dim colNumber As Long

MyRange = Sheets("MemberList").Range("B:0").Text

txtName.Text = Application.WorksheetFunction.VLookup(txtFOM.Text,
MyRange, 4, False)

End Sub


Thanks for the help




All times are GMT +1. The time now is 07:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com