Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
hhunt
 
Posts: n/a
Default Fill formulas down in macro

I'd like to create a macro that fills a formula down to the final row that
has any data.

-- Just filling to adjacent cells (e.g. double-clicking on the autofill
button) doesn't work because some of the rows don't have data in the cells
the formula is looking for.
-- I know I can select all the cells below the one I entered the formula in
and hit ctrl-D to fill the formula, but I need this macro to be able to run
no matter how many rows of data are present.
-- I tried filling the fomula all the way past the highest row number I'd
ever thought I'd reach but then (because the formula includes absolute text),
it includes all those blank rows (with just the one bit of absolute text) in
the default print area.

It's not a huge deal to just set the print area after running the macro, I
know, but I'm creating this for the use of many people so I'm trying to make
it as "one-step" as possible. Any ideas?

Thanks!
HH
  #2   Report Post  
Jason Morin
 
Posts: n/a
Default

You would use something like:

Dim iLastRow As Long
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("B1:B" & iLastRow).Filldown

This code identifies the last row (iLastRow) in col. A
with data in it, then copies the formula down in cell B1
to that last row.

HTH
Jason
Atlanta, GA

-----Original Message-----
I'd like to create a macro that fills a formula down to

the final row that
has any data.

-- Just filling to adjacent cells (e.g. double-clicking

on the autofill
button) doesn't work because some of the rows don't have

data in the cells
the formula is looking for.
-- I know I can select all the cells below the one I

entered the formula in
and hit ctrl-D to fill the formula, but I need this

macro to be able to run
no matter how many rows of data are present.
-- I tried filling the fomula all the way past the

highest row number I'd
ever thought I'd reach but then (because the formula

includes absolute text),
it includes all those blank rows (with just the one bit

of absolute text) in
the default print area.

It's not a huge deal to just set the print area after

running the macro, I
know, but I'm creating this for the use of many people

so I'm trying to make
it as "one-step" as possible. Any ideas?

Thanks!
HH
.

  #3   Report Post  
hhunt
 
Posts: n/a
Default

Thanks! It's giving me an error, but you've definitely pointed me in the
right direction. I think I'll be able to get it squared away from here.

"Jason Morin" wrote:

You would use something like:

Dim iLastRow As Long
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("B1:B" & iLastRow).Filldown

This code identifies the last row (iLastRow) in col. A
with data in it, then copies the formula down in cell B1
to that last row.

HTH
Jason
Atlanta, GA

-----Original Message-----
I'd like to create a macro that fills a formula down to

the final row that
has any data.

-- Just filling to adjacent cells (e.g. double-clicking

on the autofill
button) doesn't work because some of the rows don't have

data in the cells
the formula is looking for.
-- I know I can select all the cells below the one I

entered the formula in
and hit ctrl-D to fill the formula, but I need this

macro to be able to run
no matter how many rows of data are present.
-- I tried filling the fomula all the way past the

highest row number I'd
ever thought I'd reach but then (because the formula

includes absolute text),
it includes all those blank rows (with just the one bit

of absolute text) in
the default print area.

It's not a huge deal to just set the print area after

running the macro, I
know, but I'm creating this for the use of many people

so I'm trying to make
it as "one-step" as possible. Any ideas?

Thanks!
HH
.


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
Macro to repeat formulas in next row katiekay Excel Discussion (Misc queries) 5 February 10th 05 08:28 PM
How do I auto fill formulas dorheldav Excel Worksheet Functions 1 January 25th 05 01:48 AM
fill formulas and values Jose Mourinho Excel Discussion (Misc queries) 1 January 4th 05 03:05 PM
How do I fill down formulas so they iterate in intervals other th. picklet222 Excel Worksheet Functions 2 December 18th 04 01:23 PM
Macro for formulas MsAmethyst Excel Worksheet Functions 1 October 28th 04 06:32 PM


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