View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_2_] Don Guillett[_2_] is offline
external usenet poster
 
Posts: 1,522
Default How do I find a column number for a cell containing a value

mycolumn=application.match(myvalue,range("a1:cz1") ,0)

or use vba FIND with
if not mycol is nothing then msgbox mycol.column
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Gilgamesh" wrote in message
...
Hi,
I have a range of cells A1:CZ1 all of which have different values. I
need to find the column number for a cell that contains a certain value.
I know I can use cells.find which returns the value rather than the cell
reference, and I have seen other posts in this group to return a number
when the cell is known range(ColAddress).cells(1,1).column

I can easily put this in a simple loop but I was wondering if there was a
smarter way that could do it in one line using built-in functions. If it
was a loop it would have to be processed many times for the different
values I need to lookup slowing things down quite a bit.

Thanks