DominicB
Well-known Member
- Joined
- Oct 3, 2005
- Messages
- 1,569
Hi all
I have a piece of code which is to loop through all the worksheets in a workbook and select only those cells containing a formula, for a selective find / replace to take place. I am using the Union object thus :
This works perfectly on the first worksheet, but falls down on the next sheet in line – the debugger pointing to this command as the problem:
= Union(CellCollection, UsrRng)
Is this because the Union still contains range information from the first worksheet? How can I clear it out?
Thanks
DominicB
I have a piece of code which is to loop through all the worksheets in a workbook and select only those cells containing a formula, for a selective find / replace to take place. I am using the Union object thus :
Code:
For Each UsrRng In Selection
If UsrRng.HasFormula = True Then
Found = Found + 1
If Found = 1 Then Set CellCollection = UsrRng
If Found <> 1 Then Set CellCollection = Union(CellCollection, UsrRng)
End If
Next UsrRng
CellCollection.Select
This works perfectly on the first worksheet, but falls down on the next sheet in line – the debugger pointing to this command as the problem:
= Union(CellCollection, UsrRng)
Is this because the Union still contains range information from the first worksheet? How can I clear it out?
Thanks
DominicB