PC Review


Reply
Thread Tools Rate Thread

Build a range from a cell

 
 
tomtiv@gmail.com
Guest
Posts: n/a
 
      12th Apr 2007
I am using the OWC and i need to build a range from another range
using a starting cell.

So i have
src.address = "A23:AA24"
dest.address = "A27"

I need to calculate the end of the range based on the dest.address
cell.
the end result would be

dest.address = "A27:AA28"

I need to do this wil Excel vba... any ideas?

thanks
TT

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      12th Apr 2007
Try this:

Dim src As Range
Dim dest As Range

Set src = Range("A23:AA24")
Set dest = Range("A27")

Set dest = src.Offset(dest.Row - src.Row, dest.Column - src.Column)





"(E-Mail Removed)" wrote:

> I am using the OWC and i need to build a range from another range
> using a starting cell.
>
> So i have
> src.address = "A23:AA24"
> dest.address = "A27"
>
> I need to calculate the end of the range based on the dest.address
> cell.
> the end result would be
>
> dest.address = "A27:AA28"
>
> I need to do this wil Excel vba... any ideas?
>
> thanks
> TT
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      12th Apr 2007
Set src = Range("A23:AA24")
Set dest = Range("A27")

With src
Set dest = dest.Resize(.Rows.Count, .Columns.Count)
End With

Debug.Print dest.Address ' $A$27:$AA$28

Before resizing you might also want to ensure the new range does would not
extend off the sheet.

Regards,
Peter T

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am using the OWC and i need to build a range from another range
> using a starting cell.
>
> So i have
> src.address = "A23:AA24"
> dest.address = "A27"
>
> I need to calculate the end of the range based on the dest.address
> cell.
> the end result would be
>
> dest.address = "A27:AA28"
>
> I need to do this wil Excel vba... any ideas?
>
> thanks
> TT
>



 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      12th Apr 2007
Give this a whirl...

Sub test()
Dim src As Range
Dim dest As Range

Set src = Range("A23:AA24")
Set dest = Range("A27").Resize(src.Rows.Count, src.Columns.Count)
MsgBox dest.Address
End Sub
--
HTH...

Jim Thomlinson


"(E-Mail Removed)" wrote:

> I am using the OWC and i need to build a range from another range
> using a starting cell.
>
> So i have
> src.address = "A23:AA24"
> dest.address = "A27"
>
> I need to calculate the end of the range based on the dest.address
> cell.
> the end result would be
>
> dest.address = "A27:AA28"
>
> I need to do this wil Excel vba... any ideas?
>
> thanks
> TT
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NEED VBA TO SELECT A CELL; NOTE THE CELL VALUE;COPYADJ CELL;FIND CELL VALUE IN A RANGE AND SO ON CAPTGNVR Microsoft Excel Programming 2 8th Jul 2007 04:18 PM
The Next Build Shall be RTM guys not any other builds unless MS decides to do one more build because of bugs before RTM RC2 build 5477 is the last build before RTM Drew Windows Vista General Discussion 8 13th Oct 2006 12:41 AM
HD I build funct @if cell=AorBorC then ...else if cell=DorE then =?Utf-8?B?Sm9ja29fTWFjRHVmZjExNg==?= Microsoft Excel Worksheet Functions 8 15th Aug 2005 01:16 PM
Change cell colour for a cell or range within a predefined range =?Utf-8?B?TWFydGlu?= Microsoft Excel Programming 2 23rd May 2005 06:16 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Microsoft Excel Programming 12 10th Jun 2004 04:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:25 PM.