anglais428
Well-known Member
- Joined
- Nov 23, 2009
- Messages
- 634
- Office Version
- 2016
- Platform
- Windows
Hi,
I am looking to define a list in VBA and then use that list as the range in a vlookup formula.
Something like the below:
MyRange = Array("AA","AB")
Result = Application.VLookup(Left(A2, 2), MyRange, 1, False)
The ideal results would be if whatever the first two digits of the text in cell A2 is contained in MyRange then it will return those two digits - else it with provide a #N/A error. E.g. if AA001 is in cell A2, the result would be "AA"; if it was "AC" then the result would be "#N/A".
Any ideas?
I am looking to define a list in VBA and then use that list as the range in a vlookup formula.
Something like the below:
MyRange = Array("AA","AB")
Result = Application.VLookup(Left(A2, 2), MyRange, 1, False)
The ideal results would be if whatever the first two digits of the text in cell A2 is contained in MyRange then it will return those two digits - else it with provide a #N/A error. E.g. if AA001 is in cell A2, the result would be "AA"; if it was "AC" then the result would be "#N/A".
Any ideas?