Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Range within a Range

Morning,

I've got a matrix set up in excel which is a named range.
I want to extract a subset from this matrix and make this a seperate range
that can be called independently. For example my matrix (A1:C3) is named
Range1, I want to code in something that will highligt (B2:C3) and make it a
range called Range2.

The data I want to apply this to is obviously much bigger and the size of
Range2 is gonig to vary across runs of the tool it's coded into.

Please can you help me with the VBA code to set this up.

Thank you!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Range within a Range

use the OFFSET function

Option Explicit

Sub xxx()


Dim target As Range
Set target = Range("range1").Offset(1, 1).Resize(2, 2)
'matricx in memory
' do something
With target
Range("F2").Resize(.Rows.Count, .Columns.Count).Value = .Value
Range("F2").Resize(.Rows.Count, .Columns.Count).Name = "range2"
End With

End Sub

"michelle439731" wrote:

Morning,

I've got a matrix set up in excel which is a named range.
I want to extract a subset from this matrix and make this a seperate range
that can be called independently. For example my matrix (A1:C3) is named
Range1, I want to code in something that will highligt (B2:C3) and make it a
range called Range2.

The data I want to apply this to is obviously much bigger and the size of
Range2 is gonig to vary across runs of the tool it's coded into.

Please can you help me with the VBA code to set this up.

Thank you!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Range within a Range

rather than dumping in to teh sheet, just do this

Target.Name = "range2"

which answers yuor question properly :)


"Patrick Molloy" wrote:

use the OFFSET function

Option Explicit

Sub xxx()


Dim target As Range
Set target = Range("range1").Offset(1, 1).Resize(2, 2)
'matricx in memory
' do something
With target
Range("F2").Resize(.Rows.Count, .Columns.Count).Value = .Value
Range("F2").Resize(.Rows.Count, .Columns.Count).Name = "range2"
End With

End Sub

"michelle439731" wrote:

Morning,

I've got a matrix set up in excel which is a named range.
I want to extract a subset from this matrix and make this a seperate range
that can be called independently. For example my matrix (A1:C3) is named
Range1, I want to code in something that will highligt (B2:C3) and make it a
range called Range2.

The data I want to apply this to is obviously much bigger and the size of
Range2 is gonig to vary across runs of the tool it's coded into.

Please can you help me with the VBA code to set this up.

Thank you!

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
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM
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 03:08 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"