LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range WrapText and AutoFit with Bold Peter Gummer Excel Programming 4 February 28th 06 03:37 AM
Merge cells, Wraptext & Protect Stuart[_5_] Excel Programming 0 July 2nd 04 07:10 PM
wraptext is not updating when using references to another cell Jurry Excel Programming 7 April 23rd 04 04:23 PM
Convert from WrapText Stuart[_5_] Excel Programming 8 April 20th 04 10:23 AM
Convert from WrapText scoobydeux[_2_] Excel Programming 0 April 18th 04 03:32 PM


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"