Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Jody Mills   on Oct 21 In MS Office Category.

  
Question Answered By: Alexander Bouchard   on Oct 21

No, not necessary. What you do is put

On Error Resume Next

immediately before the statement in question and then

On Error GoTo 0

immediately after it.

From my example:

> XX = "No"
> On Error Resume Next
> XX = Target.Name.Name
> On Error GoTo 0

Better, though, is to encapsulate the bit of code  involved into a
function (or subroutine). This is a little function from my common
functions that returns the name of a range  if it has one.

Public Function CellRangeName(ByVal TheCell As Range) As String
CellRangeName = ""
On Error Resume Next
CellRangeName = TheCell.Name.Name
End Function

In this case, the On Error will be cancelled when the function finishes.

I agree with the awkward look of the double  negative, but there is no "is
something" unfortunately.

I also like Tou's comparison of addresses. It certainly has a "clean" feel
to it.

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Testing for the Named Range of Target Or get search suggestion and latest updates.


Tagged: