Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Is there a built-in function to combine 2 ranges?

Before you answer Union(), read on...

I need a function to combine 2 ranges that return 1 range encompassing
both.

Given,
range1 = "A1:D10"
range2 = "C5:F23"

Union(range1, range2) would return "A1:D10,C5:F23", but I want
something that returns "A1:F23".

I could probably write something in a few minutes, but I prefer built-
in functions where possible.

Thanks,

Nick Hebb
BreezeTree Software
http://www.breezetree.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Is there a built-in function to combine 2 ranges?

Range takes 2 arguments so something like this perhaps...

Dim rng As Range

Set rng = Range(Range("A1:D10"), Range("C5:F23"))
MsgBox rng.Address

--
HTH...

Jim Thomlinson


"Nick Hebb" wrote:

Before you answer Union(), read on...

I need a function to combine 2 ranges that return 1 range encompassing
both.

Given,
range1 = "A1:D10"
range2 = "C5:F23"

Union(range1, range2) would return "A1:D10,C5:F23", but I want
something that returns "A1:F23".

I could probably write something in a few minutes, but I prefer built-
in functions where possible.

Thanks,

Nick Hebb
BreezeTree Software
http://www.breezetree.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Is there a built-in function to combine 2 ranges?

Thanks Jim -

Nice simple solution. I thought I needed to break apart the
constituent components (min row, max row, min column, max column) to
feed into Range. I'd be embarrassed to show the convoluted code I came
up with!

Thanks,

Nick Hebb
BreezeTree Software
http://www.breezetree.com


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Is there a built-in function to combine 2 ranges?

One day we can compare embarassing code. I promise you it will be quite a
contest...
--
HTH...

Jim Thomlinson


"Nick Hebb" wrote:

Thanks Jim -

Nice simple solution. I thought I needed to break apart the
constituent components (min row, max row, min column, max column) to
feed into Range. I'd be embarrassed to show the convoluted code I came
up with!

Thanks,

Nick Hebb
BreezeTree Software
http://www.breezetree.com



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Is there a built-in function to combine 2 ranges?

Not sure what you mean by "built-in functions" in this context, but how
about

Set rng3 = Range(rng1(1, 1), rng2(rng2.Rows.Count, rng2.Columns.Count))

Alan Beban

Nick Hebb wrote:
Before you answer Union(), read on...

I need a function to combine 2 ranges that return 1 range encompassing
both.

Given,
range1 = "A1:D10"
range2 = "C5:F23"

Union(range1, range2) would return "A1:D10,C5:F23", but I want
something that returns "A1:F23".

I could probably write something in a few minutes, but I prefer built-
in functions where possible.

Thanks,

Nick Hebb
BreezeTree Software
http://www.breezetree.com

Reply
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
Bug in a built-in VBA date function? suomi Excel Programming 1 January 9th 07 10:09 PM
Built-in for Selecting Ranges? jdawson Excel Programming 2 March 6th 06 08:01 PM
Use An Excel Built-In Function Entirely Within VBA MDW Excel Programming 3 February 23rd 06 10:03 PM
combine two ranges rtos Excel Programming 1 April 3rd 04 09:44 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 04:16 AM.

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

About Us

"It's about Microsoft Excel"