problem with find in merged cells
Hi Antonio,
That works fine for me, ie your sample text in merged cells. It might not
work if:
- Previously set Find options are not what you require, eg Match case and/or
Entire Cells are ticked. Set options as required in code.
- The text does not exist in whatever range you qualified .Find with. Try
Activesheet.Cells
Regards,
Peter T
"Antonio" wrote in message
...
I thought I had this VBA pretty under control, but this one is new to me.
set r = .Find(" - Open Positions ( August 03, 2007 )")
returns nothing even though there is cell with that value
The only peculiarity of that cell is that is merged with others
Is the find function not supposed to work for merged cells?
Thanks,
Antonio
Code and sheet follows:
Sub main()
Dim r As Range
Dim match_address As String
Dim st As String
st = Worksheets(1).Range("A3").Value
With Worksheets(1).Columns("A")
Set r = .Find(st)
If Not r Is Nothing Then
match_address = r.Address
End If
End With
End Sub
Sheet:
Average Credit Balance 51,608.69 51,608.69 0
- Open Positions ( August 03, 2007 )
Stocks
Symbol Open Quantity Mult Open Price Close Price Cost Basis Value
Unrealized
P/L
EUR
CS -- 7,000 1 -- -- 28.25 197,750.00 --
EAD -- 8,000 1 -- -- 21.92 175,360.00 --
FPB -- 5,000 1 -- -- 54.71 273,550.00 --
|