Error Control - null rnage

T

Tim Childs

Hi

What test can be used to stop the following code

Range(.Cells(iFirstDataRow, iTestCol), .Cells(lFinalRow,
iTestCol)).SpecialCells(xlCellTypeFormulas, 7)
erroring when there are no cells identified by the Goto-Special command?

i.e. I sometimes get error 1004 - "no cells were found"

thanks

Tim
 
J

James Ravenswood

Hi

What test can be used to stop the following code

Range(.Cells(iFirstDataRow, iTestCol), .Cells(lFinalRow,
iTestCol)).SpecialCells(xlCellTypeFormulas, 7)
erroring when there are no cells identified by the Goto-Special command?

i.e. I sometimes get error 1004 - "no cells were found"

thanks

Tim

Hi Tim:

You need to trap the error:

Sub marine()
Dim r As Range
On Error Resume Next
Set r = Cells.SpecialCells(xlCellTypeFormulas)
If r Is Nothing Then
MsgBox "r is nothing"
End If
End Sub
 
T

Tim Childs

Hi

What test can be used to stop the following code

Range(.Cells(iFirstDataRow, iTestCol), .Cells(lFinalRow,
iTestCol)).SpecialCells(xlCellTypeFormulas, 7)
erroring when there are no cells identified by the Goto-Special command?

i.e. I sometimes get error 1004 - "no cells were found"

thanks

Tim

Hi Tim:

You need to trap the error:

Sub marine()
Dim r As Range
On Error Resume Next
Set r = Cells.SpecialCells(xlCellTypeFormulas)
If r Is Nothing Then
MsgBox "r is nothing"
End If
End Sub
 
T

Tim Childs

Hi James

Many thanks for that solution

bw

Tim

Hi

What test can be used to stop the following code

Range(.Cells(iFirstDataRow, iTestCol), .Cells(lFinalRow,
iTestCol)).SpecialCells(xlCellTypeFormulas, 7)
erroring when there are no cells identified by the Goto-Special command?

i.e. I sometimes get error 1004 - "no cells were found"

thanks

Tim

Hi Tim:

You need to trap the error:

Sub marine()
Dim r As Range
On Error Resume Next
Set r = Cells.SpecialCells(xlCellTypeFormulas)
If r Is Nothing Then
MsgBox "r is nothing"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top