[RESOLVED] Return the column position of found value within a range
Hi
I have a named range that sits in range D1 to H1. My program uses the FIND method to check that a value exists in the named range. When the value exists then I want to return the position within the range but the following is giving me the position on the worksheet.
Code:
DiscountColumn = Sheet4.range("ExportHeadings").Find(What:=DiscountString, MatchCase:=False).Column
So if the value is found in the first position within the named range then I expect the 1 to be returned and not the value 4.
I know I could loop through the range to find the value as it's a small range but I read that the FIND method is much more efficient.
Is it possible to return the position from within the named range?
Thanks
Re: Return the column position of found value within a range
you would need to compare the found column with the range column like
Code:
DiscountColumn = Sheet4.range("ExportHeadings").Find(What:=DiscountString, MatchCase:=False).Column - Sheet4.range("ExportHeadings").Column +1