PDA

View Full Version : very simple one



rayoconnell
05-17-2007, 07:17 AM
Just trying to do a "Lookat" to try and find a specific word in the first 3 rows of cells.
Lookat Columns ("A1:A3")

this is throwing up an error.
if i leave the 1 and 3 out then it will search the first row alright.

Any help!!

Bob Phillips
05-17-2007, 08:04 AM
ARe you referring to Find? Can you show the code you are using?

rayoconnell
05-17-2007, 08:26 AM
i am trying to find the first instance of "alias" in rows 1-3 in excel.
it works fine usually but if the first 2 cells are merged and "alias" is in the merged cell then it will miss it. is it possable to avoid this!!!!

Bob Phillips
05-17-2007, 08:28 AM
Yeah, don't use merged cells, they are more trouble than they are worth.

rayoconnell
05-17-2007, 08:31 AM
id love to but its a clients document and i cant get around it.

Bob Phillips
05-17-2007, 08:38 AM
I assume that the merge is in A1:A2?

Never use merged cell;s, so don't know if there is a better way than this



Dim oCell As Range
Dim oArea As Range

For Each oArea In Rows("1:3").Areas
For Each oCell In oArea.Cells
If oCell.Value = "alias" Then
MsgBox oCell.MergeArea.Address
End If
Next oCell
Next oArea