Run-Time error '1004': No cells were found
Regina,
The best method to see why nothing is happening is to debug the code by
walking through it.
Click on the line Set r = ..
Press F9
This will set a break point on the line.
Run the macro by pressing F5.
The yellow line will appear and will overlap the break point.
Now step through the code by pressing F8
If your code skips over the line
r.Clear
then it means the code did not find any cells containing constants.
If it goes into that line (that is the line r.Clear becomes yellow) then you
can check the address of the cells which the code found to be the cells
containing the constants by typeing ? r.address in the immediate window. (If
the immediate window is not in view type Control-G to view it)
Hope this helps.
"Regina" wrote:
Hi Alok,
I copied your reply directly into the macro and it didn't do any actions.
It didn't error but there wasn't any action either. Thanks for you help!
Any other suggestions?
--
Regina
"Alok" wrote:
Regina,
Try this
Sub clear_part2()
Dim r As Range
On Error Resume Next
Set r = Range("D7:E125").SpecialCells(xlCellTypeConstants)
On Error GoTo 0
If Not r Is Nothing Then
r.Clear
End If
End Sub
"Regina" wrote:
The subject line is the error message I get when trying to run the following
code. When I hit debug, it highlights the line that starts with "set r -
range...". What I am trying to do is clear the constants but leave the
formulas in the "D7:E125" Range. Help!!!!
' Sub clear_part2()
Dim r As Range
Set r = Range("D7:E125").SpecialCells(xlCellTypeConstants)
r.Clear
End Sub
--
Regina
|