Brucefield
New Member
- Joined
- Apr 23, 2009
- Messages
- 3
I'm trying to use VLOOKUP in VBA to add a value to a variable:
The macro stops at this line with the following error
What I'm trying to do: Range "TeamNameLookup" is in the active file, albeit in a different sheet. It's 4 columns wide, and the value I want to return is in column 3. The variable "TeamName" is populated with a value that's definitely in the first column of the named range. My feel is that for some reason Excel/VBA wants an object attached to the end of Range("TeamNameLookup"), if only because that's the only bit of the code that could possibly have an object added to it!
Any thoughts? Thanks in advance!
LizTeamName = Application.WorksheetFunction.VLookup(TeamName, Range("TeamNameLookup"), 3, False).Value
The macro stops at this line with the following error
Run-time error '424': Object Required
What I'm trying to do: Range "TeamNameLookup" is in the active file, albeit in a different sheet. It's 4 columns wide, and the value I want to return is in column 3. The variable "TeamName" is populated with a value that's definitely in the first column of the named range. My feel is that for some reason Excel/VBA wants an object attached to the end of Range("TeamNameLookup"), if only because that's the only bit of the code that could possibly have an object added to it!
Any thoughts? Thanks in advance!