Originally Posted by
teylyn
Hello,
just glancing over the code, without actually running it.
- you use Vlookup with a 1 as the return column. That could more easily be achieved with Match() instead, since you are returning the search term if it can ber found. Match() would be much leaner. As a formula, something like
=if(Match(lookupTerm, LookupRange, 0),lookupTerm,"")
I see what you are saying; I chose the VLOOKUP simply because it is what I am familiar with. Obviously, I need to learn about the MATCH function. Still, my question applies here as well though. How would I designate "LookupRange" if using VBA to accomplish this task? The range would be dynamic in that the number of rows will not always be the same. Following your example, I guess I could have said:
I am not sure if "J:J" would have worked or not.
Originally Posted by
teylyn
- you use Vlookup with "False" as the last parameter. This does not require the lookup range to be sorted at all. It can be in any order. So why go through the sorting routine in the first place?
I thought sorting in ascending order was required for this.
Originally Posted by
teylyn
What are you trying to achieve?
I am trying to write a macro that looks up values in one sheet or one workbook and finds them in another sheet or another workbook where the columns of info are known, but the number of rows will change. I was simply wondering how to write a formula such as VLOOKUP, where the range argument is always changing. Using a range that is named is easy enough, but I thought named ranges were new to Excel 2007 or 2010. So I wanted to understand VBA code for inserting this type of function without using named ranges.
Bookmarks