If I understand this, the user enters a value, and you want to use that value to find a column corresponding to it elsewhere in the book?
If the user is entering the column number, then OBP's solution will work.
If you want to find the column in the sheet that matches the user entered value, then you probably don't need to hassle with VBA at all, and you can get by with the MATCH() function. Syntax MATCH(lookup_value,lookup_array,match_type)
it can be used to find an exact match (0), next lowest value(-1), or next highest value(1).
If it is something best left to VBA, I personally despise the syntax for VBA's find function and instead I'd probably use the WorksheetFunction property to call Match from inside my code, like this example:
answer = Application.WorksheetFunction.Match(UserValueCell, LookupRange,0)
I hope that helps. |