Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Moving into a cell range using Offset and LBound

I need to copy a formula to an empty column on a number of spreadsheets.
Ihave brokendown the task in the following 3 steps:
1. The only reference that I have about the size of each range in the empty
column is the data entered on the previous column.
So I capture the known range by:
Dim VarT as Variant
VarT = Range("a1").Select
Range(Selection, Selection.End(xlDown)).Select

2. Since I need range VarT to be located in cell B1 (start of range with
VarT dimensions) I have tried the following:
Dim FinalRange as Range
Set FinalRange = Selection.Offset(0, 1).Range(LBound(VarT)).Select
With the idea that this will displace me to the start of the required range.

3. Where I can finally code formula as:
ActiveCell.FormulaR1C1 = "=********"
FinalRange.Select
Selection.AutoFill Destination:=FinalRange, Type:=xlFillDefault
FinalRange.Select
At the moment I am not able to pass step 2. For some reason I am not able to
move into the final range required.
Offset only works with cell therefore i thought that using Lbound will get
me starting position of VarT range and be able to be displaced using Offset.
But no luck so far
Is my thinking correct?
If someone can help I would appreciate it

  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Moving into a cell range using Offset and LBound

You can probably do it in one stage:
Defining your range using it's first and last cells

first cell:
row = 1
column = 2

last cell:
row = cells(65536,1).end(xlup).row
column=2

'so you end up with
range(cells(1,2),cells(cells(65536,1).end(xlup).ro w,2).formula="=whatever"



"TISR" wrote:

I need to copy a formula to an empty column on a number of spreadsheets.
Ihave brokendown the task in the following 3 steps:
1. The only reference that I have about the size of each range in the empty
column is the data entered on the previous column.
So I capture the known range by:
Dim VarT as Variant
VarT = Range("a1").Select
Range(Selection, Selection.End(xlDown)).Select

2. Since I need range VarT to be located in cell B1 (start of range with
VarT dimensions) I have tried the following:
Dim FinalRange as Range
Set FinalRange = Selection.Offset(0, 1).Range(LBound(VarT)).Select
With the idea that this will displace me to the start of the required range.

3. Where I can finally code formula as:
ActiveCell.FormulaR1C1 = "=********"
FinalRange.Select
Selection.AutoFill Destination:=FinalRange, Type:=xlFillDefault
FinalRange.Select
At the moment I am not able to pass step 2. For some reason I am not able to
move into the final range required.
Offset only works with cell therefore i thought that using Lbound will get
me starting position of VarT range and be able to be displaced using Offset.
But no luck so far
Is my thinking correct?
If someone can help I would appreciate it

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Moving into a cell range using Offset and LBound

Many Thanks Rob
Your use of cells and range is more efficient.

"Rob" wrote:

You can probably do it in one stage:
Defining your range using it's first and last cells

first cell:
row = 1
column = 2

last cell:
row = cells(65536,1).end(xlup).row
column=2

'so you end up with
range(cells(1,2),cells(cells(65536,1).end(xlup).ro w,2).formula="=whatever"



"TISR" wrote:

I need to copy a formula to an empty column on a number of spreadsheets.
Ihave brokendown the task in the following 3 steps:
1. The only reference that I have about the size of each range in the empty
column is the data entered on the previous column.
So I capture the known range by:
Dim VarT as Variant
VarT = Range("a1").Select
Range(Selection, Selection.End(xlDown)).Select

2. Since I need range VarT to be located in cell B1 (start of range with
VarT dimensions) I have tried the following:
Dim FinalRange as Range
Set FinalRange = Selection.Offset(0, 1).Range(LBound(VarT)).Select
With the idea that this will displace me to the start of the required range.

3. Where I can finally code formula as:
ActiveCell.FormulaR1C1 = "=********"
FinalRange.Select
Selection.AutoFill Destination:=FinalRange, Type:=xlFillDefault
FinalRange.Select
At the moment I am not able to pass step 2. For some reason I am not able to
move into the final range required.
Offset only works with cell therefore i thought that using Lbound will get
me starting position of VarT range and be able to be displaced using Offset.
But no luck so far
Is my thinking correct?
If someone can help I would appreciate it

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
Sum variable range of column entries in offset cell Struggling in Sheffield[_2_] New Users to Excel 2 October 12th 09 09:11 PM
Sum variable range of column entries in offset cell Struggling in Sheffield[_2_] New Users to Excel 5 October 10th 09 05:16 PM
Offset Function works in cell, not in named range DragonslayerApps Excel Worksheet Functions 0 July 25th 05 04:39 PM
Selecting a range offset from a cell Beeegr8 Excel Programming 2 April 1st 05 08:02 PM
Selecting cell using range.offset presence76[_3_] Excel Programming 2 June 9th 04 03:46 PM


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