If True then DO, otherwise DON"T
Then you would need a loop and more complex code...
Sub RemoveAvgPricesBOD()
Dim C As Range
Dim FirstAddress As String
On Error GoTo NotFound
Set C = Cells.Find(What:="Average Prices")
If Not C Is Nothing Then
FirstAddress = C.Address
Do
C.EntireRow.ClearContents
Set C = Cells.FindNext(C)
Loop While Not C Is Nothing And C.Address < FirstAddress
End If
NotFound:
End Sub
--
Rick (MVP - Excel)
"MikeF" wrote in message
...
Thanx again, Rick.
One more query --- What if there were multiple rows that contain "Average
Prices" ...
How would I select all of them at the same time?
Regards,
- Mike
"Rick Rothstein" wrote:
Since you are only attempting to do one Find operation and nothing else
after it, you could what you want this way...
Sub RemoveAvgPricesBOD()
On Error Resume Next
Cells.Find(What:="Average Prices").EntireRow.ClearContents
End Sub
--
Rick (MVP - Excel)
"MikeF" wrote in message
...
This should be very simple, but can't seem to make it work properly ..
The following procedure is called from another as application.run.
All it needs to do is delete the only row that contains the text
Average
Prices.
... If the text Average Prices doesn't exist, don't delete anything/do
nothing and move on.
Thanx in advance for any assistance.
- Mike
Sub RemoveAvgPricesBOD()
On Error Resume Next
If Cells.Find(What:="Average Prices") = True Then
Cells.Find(What:="Average Prices").EntireRow.ClearContents
If Cells.Find(What:="Average Prices") = False Then
Exit Sub
End If
End If
End Sub
|