Remove WrapText
Not sure why I used RefersToRange, as you say it would fail if the address
length is close to 255 or more. Normally I use simply
set rng = Range(nmName)
FWIW my example also caters your point a) as well as b).
Regards,
Peter T
"Tom Ogilvy" wrote in message
...
Now that I posted, looks like there are a lot of posts.
All are pretty much the same. The reason mine seems somewhat verbose is
a. I check that the named range is actually a range - all are not. If it
isn't a range and you try to use it as a range, you get an error.
b. I Check that if it is a range, it is on the same sheet as A1:H400 - if
not, attempting an intersect will lead to an error. (Peter T also tested
for
this)
c. I used Evaluate rather than RefersToRange because if a name contains a
large number of areas, it can cause an error when using RefersToRange.
You
could also use Application.Range(nm.name) rather than evaluate.
Comments only provided for information for the OP, not as criticism.
--
Regards,
Tom Ogilvy
"Tom Ogilvy" wrote:
Sub ABC()
Dim nm As Name, rng As Range
Dim rng1 As Range, rng2 As Range
For Each nm In ThisWorkbook.Names
Set rng = Nothing
On Error Resume Next
Set rng = Evaluate(nm.Name)
On Error GoTo 0
If Not rng Is Nothing Then
If rng.Parent.Name = ActiveSheet.Name Then
Set rng1 = Nothing
Set rng1 = Intersect(rng, Range("A1:H400"))
If Not rng1 Is Nothing Then
If rng2 Is Nothing Then
Set rng2 = rng1
Else
Set rng2 = Union(rng2, rng1)
End If
End If
End If
End If
Next
If Not rng2 Is Nothing Then
rng2.WrapText = False
msgbox rng2.Address
End If
End Sub
--
Regards,
Tom Ogilvy
"Alex St-Pierre" wrote:
Hi,
I would like to remove WrapText for each each in range(A1:H400) that
has a
named range. The fastest way should be to defined a range that
contains only
the named range and then, I could apply rng.WrapText = False. Any
idea?
Thanks!
Alex
--
Alex St-Pierre
|