Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variable Range Length & .FillDown?

Hi all,

I'm putting together some code for a member of our Lending department.
Here's what the code is meant to do:

1. In cell B11, the user will enter the term of a loan in months (eg,
12, 24, 36, etc).

2. A table will then be generated on the same sheet, showing monthly
repayments and other info. The *depth* of that table (ie, its number
of rows) will match the term entered in B11.

For example, if the value in B11 is 12, the table will have a depth of
12 rows.

3. In the left-most column of that table, the EOMonth formula (from
the 'Analysis Toolpack' add-in) will appear. It needs to be filled
down to the bottom of that column.

Here's the issue I'm grappling with: given that the depth of that
column is variable (ie, is dependent upon the value in B11), can I
build a Range("??:??").FillDown statement that accepts a *variable*
address?

For example, if the value in B11 is 12, and the top-left cell of the
resultant table is E23, the bottom-left cell in the table would be E34
(ie, a depth of 12 rows). But if B11 = 13, the address of the table's
bottom-left cell would be E35.

Here's how I've tried to build this flexibility in to the
Range("??:??").FillDown statement......but it throws up a syntax error:

_________________________________________________

Sub PopulateTable()
Dim newTerm

' Get the duration of the Loan Term from cell B11 (eg, 12, 24, 36, etc)
Set newTerm = Worksheets("Sheet1").Range("B11")

' Write the EOMONTH formula in top-left cell of the table
Range("E23").Formula = "=EOMONTH(B10,0)"

' Fill down from E23, giving the table a depth = the value in 'newTerm'
Range("E23").Activate
Range("E23: & ActiveCell.Offset(rowOffset:=(newTerm - 1)) &
").FillDown

End Sub
_________________________________________________

Does that make any sense to you guys? :)

Any help would be much appreciated.

Cheers,

Jason Paris

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Variable Range Length & .FillDown?

Range("E23").Resize(newTerm, 1).Formula = "=EOMONTH(B10,0)"

HTH
--
AP

"Jason Paris" a écrit dans le message de news:
...
Hi all,

I'm putting together some code for a member of our Lending department.
Here's what the code is meant to do:

1. In cell B11, the user will enter the term of a loan in months (eg,
12, 24, 36, etc).

2. A table will then be generated on the same sheet, showing monthly
repayments and other info. The *depth* of that table (ie, its number
of rows) will match the term entered in B11.

For example, if the value in B11 is 12, the table will have a depth of
12 rows.

3. In the left-most column of that table, the EOMonth formula (from
the 'Analysis Toolpack' add-in) will appear. It needs to be filled
down to the bottom of that column.

Here's the issue I'm grappling with: given that the depth of that
column is variable (ie, is dependent upon the value in B11), can I
build a Range("??:??").FillDown statement that accepts a *variable*
address?

For example, if the value in B11 is 12, and the top-left cell of the
resultant table is E23, the bottom-left cell in the table would be E34
(ie, a depth of 12 rows). But if B11 = 13, the address of the table's
bottom-left cell would be E35.

Here's how I've tried to build this flexibility in to the
Range("??:??").FillDown statement......but it throws up a syntax error:

_________________________________________________

Sub PopulateTable()
Dim newTerm

' Get the duration of the Loan Term from cell B11 (eg, 12, 24, 36, etc)
Set newTerm = Worksheets("Sheet1").Range("B11")

' Write the EOMONTH formula in top-left cell of the table
Range("E23").Formula = "=EOMONTH(B10,0)"

' Fill down from E23, giving the table a depth = the value in 'newTerm'
Range("E23").Activate
Range("E23: & ActiveCell.Offset(rowOffset:=(newTerm - 1)) &
").FillDown

End Sub
_________________________________________________

Does that make any sense to you guys? :)

Any help would be much appreciated.

Cheers,

Jason Paris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Variable Range Length & .FillDown?

you can try something like this, spelled out so you can follow it

Range("e23:e" & Range("e23").Row + Range("b11").Value).FillDown

or this

Range("e23:e" & 23 + Range("b11").Value).FillDown

--


Gary


"Jason Paris" wrote in message
oups.com...
Hi all,

I'm putting together some code for a member of our Lending department.
Here's what the code is meant to do:

1. In cell B11, the user will enter the term of a loan in months (eg,
12, 24, 36, etc).

2. A table will then be generated on the same sheet, showing monthly
repayments and other info. The *depth* of that table (ie, its number
of rows) will match the term entered in B11.

For example, if the value in B11 is 12, the table will have a depth of
12 rows.

3. In the left-most column of that table, the EOMonth formula (from
the 'Analysis Toolpack' add-in) will appear. It needs to be filled
down to the bottom of that column.

Here's the issue I'm grappling with: given that the depth of that
column is variable (ie, is dependent upon the value in B11), can I
build a Range("??:??").FillDown statement that accepts a *variable*
address?

For example, if the value in B11 is 12, and the top-left cell of the
resultant table is E23, the bottom-left cell in the table would be E34
(ie, a depth of 12 rows). But if B11 = 13, the address of the table's
bottom-left cell would be E35.

Here's how I've tried to build this flexibility in to the
Range("??:??").FillDown statement......but it throws up a syntax error:

_________________________________________________

Sub PopulateTable()
Dim newTerm

' Get the duration of the Loan Term from cell B11 (eg, 12, 24, 36, etc)
Set newTerm = Worksheets("Sheet1").Range("B11")

' Write the EOMONTH formula in top-left cell of the table
Range("E23").Formula = "=EOMONTH(B10,0)"

' Fill down from E23, giving the table a depth = the value in 'newTerm'
Range("E23").Activate
Range("E23: & ActiveCell.Offset(rowOffset:=(newTerm - 1)) &
").FillDown

End Sub
_________________________________________________

Does that make any sense to you guys? :)

Any help would be much appreciated.

Cheers,

Jason Paris



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
Find/Copy Variable length range [email protected] Excel Programming 0 March 6th 06 07:50 PM
Variable series length/range JessK Charts and Charting in Excel 1 March 3rd 06 04:02 AM
Copying RANGE of variable length Pele Excel Programming 2 October 19th 05 06:00 PM
Printing Variable Length (but Not Width) Range Chuckles123[_44_] Excel Programming 0 November 5th 04 11:19 PM
Using a Macro to Sum a Variable-Length Range (a Column) Chuckles123 Excel Programming 2 October 3rd 04 01:12 PM


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