LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Set Range Var with address length over 256

I want to set a range variable with the address of
variable already set in another workbook. The problem is
if the address length is more than 256 (approx 17 to 25
areas).

The following seems to work, but the Loop & Union method
is slow with a very large number of areas.

Sub CopyRngVar()
Dim Rng1 As Range 'in active WB
Dim Rng2 As Range 'destined another WB
Dim a As Range

Set Rng1 = Range("A1:B3,A5:B6")

With Workbooks("Book2").Worksheets("Sheet1")

'this works if address length < 256
'Set Rng2 = .Range(Rng1.Address)

For Each a In Rng1.Areas
If Rng2 Is Nothing Then
Set Rng2 = .Range(a.Address)
Else
Set Rng2 = Union(Rng2, .Range(a.Address))
End If
Next

End With
Rng2.Interior.ColorIndex = 5

End Sub

Any ideas for a something more efficient much appreciated,
TIA,
Sandy

Savituk yahoo co uk

 
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 Name Limitations - Max Refers To Length? Barb Reinhardt Excel Discussion (Misc queries) 5 May 19th 23 11:42 AM
How to create a range address with ADDRESS function? Steve McLeod Excel Worksheet Functions 1 December 18th 08 02:02 PM
Validation length, Range length I think I need to rephrase the question Excel Discussion (Misc queries) 5 September 17th 07 06:29 AM
Variable series length/range JessK Charts and Charting in Excel 1 March 3rd 06 04:02 AM
Sending email via VB - address length Carl Woodall Excel Programming 3 January 22nd 04 05:08 PM


All times are GMT +1. The time now is 09:14 AM.

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"