Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Working with a range within a range ?

I am trying to assing a sub range within a larger range of cells on a
worksheet.
I would like to be able to assign this smaller sub range within the larger
range of cells on my worksheet by just designating wich column within the
larger range should be used for the smaller range and the rest of the
paramiters such as number of rows for the smaller range should be taken from
the range paramiters of the larger range.

Set LRange = Worksheets("Sheet1").Range("A1:D10")

Set SRange = Range(LRange.Columns(1)) <-- This works but only gives me a
range of "A1" I need it to be "A1:A10"

anyone ????

Thanks again
Dan Thompson
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Working with a range within a range ?

Set LRange = Worksheets("Sheet1").Range("A1:D10")

Set SRange = LRange.Columns(1)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dan Thompson" wrote in message
...
I am trying to assing a sub range within a larger range of cells on a
worksheet.
I would like to be able to assign this smaller sub range within the larger
range of cells on my worksheet by just designating wich column within the
larger range should be used for the smaller range and the rest of the
paramiters such as number of rows for the smaller range should be taken

from
the range paramiters of the larger range.

Set LRange = Worksheets("Sheet1").Range("A1:D10")

Set SRange = Range(LRange.Columns(1)) <-- This works but only gives me a
range of "A1" I need it to be "A1:A10"

anyone ????

Thanks again
Dan Thompson



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Working with a range within a range ?

You can use the intersect function which gives you the intersection of two
ranges.

Sub SubRange()
Dim rngLarge As Range
Dim rngSmall As Range

Set rngLarge = Sheet1.Range("A1:D10")

Set rngSmall = Intersect(Sheet1.Range("A1").EntireColumn, rngLarge)
rngSmall.Select

End Sub

You can modify this as is necessary. I made some specific references.

HTH

"Dan Thompson" wrote:

I am trying to assing a sub range within a larger range of cells on a
worksheet.
I would like to be able to assign this smaller sub range within the larger
range of cells on my worksheet by just designating wich column within the
larger range should be used for the smaller range and the rest of the
paramiters such as number of rows for the smaller range should be taken from
the range paramiters of the larger range.

Set LRange = Worksheets("Sheet1").Range("A1:D10")

Set SRange = Range(LRange.Columns(1)) <-- This works but only gives me a
range of "A1" I need it to be "A1:A10"

anyone ????

Thanks again
Dan Thompson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Working with a range within a range ?

Thanks Jim your solution worked for what I need to do.

Thanks for your input too Bob. However usning your method does sort of work
but it only gives you a row count of 1 for the new sub range. This is the same
problem I was already having. Thanks anyway


"Dan Thompson" wrote:

I am trying to assing a sub range within a larger range of cells on a
worksheet.
I would like to be able to assign this smaller sub range within the larger
range of cells on my worksheet by just designating wich column within the
larger range should be used for the smaller range and the rest of the
paramiters such as number of rows for the smaller range should be taken from
the range paramiters of the larger range.

Set LRange = Worksheets("Sheet1").Range("A1:D10")

Set SRange = Range(LRange.Columns(1)) <-- This works but only gives me a
range of "A1" I need it to be "A1:A10"

anyone ????

Thanks again
Dan Thompson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Working with a range within a range ?

For me, the following displays A1:D10 and C1:C10

Sub Test()
Dim Rng1 As Range
Dim Rng2 As Range
Set Rng1 = Range("A1:D10")
Set Rng2 = Rng1.Columns(3)
Debug.Print Rng1.Address, Rng2.Address
End Sub

OTOH, this statement produces an error.

Debug.Print Range(Rng1.Columns(3)).Address

probably because Range wants 2 references rather than just 1.

On Fri, 4 Mar 2005 14:13:02 -0800, Dan Thompson
wrote:

Thanks Jim your solution worked for what I need to do.

Thanks for your input too Bob. However usning your method does sort of work
but it only gives you a row count of 1 for the new sub range. This is the

same
problem I was already having. Thanks anyway


"Dan Thompson" wrote:

I am trying to assing a sub range within a larger range of cells on a
worksheet.
I would like to be able to assign this smaller sub range within the larger
range of cells on my worksheet by just designating wich column within the
larger range should be used for the smaller range and the rest of the
paramiters such as number of rows for the smaller range should be taken

from
the range paramiters of the larger range.

Set LRange = Worksheets("Sheet1").Range("A1:D10")

Set SRange = Range(LRange.Columns(1)) <-- This works but only gives me a
range of "A1" I need it to be "A1:A10"

anyone ????

Thanks again
Dan Thompson


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
Working with the range object [email protected] Excel Discussion (Misc queries) 1 November 26th 07 04:29 PM
Working with a range Dan Chupinsky Excel Discussion (Misc queries) 3 July 6th 05 06:39 AM
Working with a selected range OkieViking Excel Programming 3 June 10th 04 07:21 PM
setting a range not working, please help Dan Mullen Excel Programming 3 May 28th 04 10:31 AM
Range selection not working kanan Excel Programming 3 April 22nd 04 05:19 PM


All times are GMT +1. The time now is 10:23 PM.

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"