PDA

View Full Version : [SOLVED] Error I recieved!!



Shaolin
04-15-2005, 10:12 AM
I ran a few tests and a window message pops up with the error

"Run-Time Error '1004' No Cells were formed"

After clicking on the "debug" button it goes to the code and the following line is highlighted


Set rngCheck = Range("K3:K3000").SpecialCells(xlCellTypeConstants, 23)

FYI, rngCheck was declared.

How do I fix this problem?

Killian
04-15-2005, 10:32 AM
As an error, it's a bit of a red herring. All that is happening is that


Range("K3:K3000").SpecialCells(xlCellTypeConstants, 23)

is not retruning anything because none of the cells in the range contain an error, number, constant or logical expression (which is what 23 is testing for)
You'll have to test the result of the function first and then call it again if it has a result


If Not Range("K3:K3000").SpecialCells(xlCellTypeConstants, 23) Is Nothing Then
Set rngCheck = Range("K3:K3000").SpecialCells(xlCellTypeConstants, 23)
End If

That seems a bit inefficient... there's probably a better way to resolve it... I'll have to have a think, but for now, that will do it

Jacob Hilderbrand
04-15-2005, 10:51 AM
What I usually do is:


On Error Resume Next
Set rngCheck = Range("K3:K3000").SpecialCells(xlCellTypeConstants, 23)
On Error Goto 0
If rngCheck Is Nothing Then
Else
End If