Thread: Search for text
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
dmthornton dmthornton is offline
external usenet poster
 
Posts: 19
Default Search for text

If you haven't found your answer yet, you could try something like this:

Dim rngCell As Range
With Sheet1
Set rngCell = .Cells.Find( _
What:="Total Life Sales", _
After:=.Range("A1"), _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext _
).Offset(0, -2)
End With

You can then use rngCell as the cell that is 2 left of "Total Life Sales"
(ex. rngCell.Select or rngCell.Value = ""). Note that if it does not find
"Total Life Sales", it will give you a runtime error.

"Hru48" wrote:


Hi,

I have a problem, I have a worksheet which changes shape quite a bit
when different data is loaded into it and I need to be able to locate
cells so I can use formula on them as part of a larger macro.

How can I locate the cell which is two to the left of the cell which
will always contain the words 'Total Life Sales'.

I was thinking this is something to do with an active cell value =
'Total Life Sales' and then offset two the the left, but i'm not sure
how to phrase it.

Any help would be grand

Cheers

Hayley


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=541618