Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
y y is offline
external usenet poster
 
Posts: 60
Default Getting a subrange of a specified range.

How can I get a subrange of a range?
Or simply a row or a column?

I'm looking for a trick like this

Supposing rng1= $A$3:$G$56

rng2=GetSubRng(rng1,2,2,4,3) <<


rng2 will be equal to $B$4:$D$7

Thanks Alex.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Getting a subrange of a specified range.

Hi
try
=rng1.offset(1,1).resize(4,3)

--
Regards
Frank Kabel
Frankfurt, Germany

"y" schrieb im Newsbeitrag
...
How can I get a subrange of a range?
Or simply a row or a column?

I'm looking for a trick like this

Supposing rng1= $A$3:$G$56

rng2=GetSubRng(rng1,2,2,4,3) <<


rng2 will be equal to $B$4:$D$7

Thanks Alex.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Getting a subrange of a specified range.

Frank Kabel wrote:
Or = Range(rng1(2, 2), rng1(5, 4))

Not sure what your 2,2,4,3 is supposed to represent.

Alan Beban
Hi
try
=rng1.offset(1,1).resize(4,3)

--
Regards
Frank Kabel
Frankfurt, Germany

"y" schrieb im Newsbeitrag
...

How can I get a subrange of a range?
Or simply a row or a column?

I'm looking for a trick like this

Supposing rng1= $A$3:$G$56

rng2=GetSubRng(rng1,2,2,4,3) <<


rng2 will be equal to $B$4:$D$7

Thanks Alex.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Getting a subrange of a specified range.

Hi Alan
i was also gueesing but as the OP did not respond either i hit the
point or he did not read it :-)

--
Regards
Frank Kabel
Frankfurt, Germany

"Alan Beban" schrieb im Newsbeitrag
...
Frank Kabel wrote:
Or = Range(rng1(2, 2), rng1(5, 4))

Not sure what your 2,2,4,3 is supposed to represent.

Alan Beban
Hi
try
=rng1.offset(1,1).resize(4,3)

--
Regards
Frank Kabel
Frankfurt, Germany

"y" schrieb im Newsbeitrag
...

How can I get a subrange of a range?
Or simply a row or a column?

I'm looking for a trick like this

Supposing rng1= $A$3:$G$56

rng2=GetSubRng(rng1,2,2,4,3) <<

rng2 will be equal to $B$4:$D$7

Thanks Alex.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 733
Default Getting a subrange of a specified range.

"Alan Beban" wrote...
Or = Range(rng1(2, 2), rng1(5, 4))

Not sure what your 2,2,4,3 is supposed to represent.

....
Frank Kabel wrote:

....
=rng1.offset(1,1).resize(4,3)

....
"y" schrieb im Newsbeitrag

....
I'm looking for a trick like this

Supposing rng1= $A$3:$G$56

rng2=GetSubRng(rng1,2,2,4,3)

rng2 will be equal to $B$4:$D$7


Given rng1 and the intended rng2, one guess for 2,2,4,3 would be something
like =OFFSET(INDEX(rng1,2,2),0,0,4,3), which suggests

Set rng2 = rng1.Cells(2, 2).Resize(4, 3)

which could be implemented as


Function GetSubRange(rng1 As Range, ir As Long, ic As Long, _
nr As Long, nc As Long) As Range

On Error Resume Next
Set GetSubRange = rng1.Cells(ir, ic).Resize(nr, nc)

End Function


which would preserve the OP's argument semantics.




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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Subrange Oscar Excel Worksheet Functions 5 August 8th 08 09:05 PM
Copy subrange without macros Tony Starr Excel Worksheet Functions 5 August 13th 07 02:06 PM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


All times are GMT +1. The time now is 09:53 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"