Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying formula to the bottom of a range

I'm trying to create a macro that copies a formula in a column down to the
bottom of a range.

For example, I have data in columns A - L. In column M, I want to create a
formula and copy it down to the bottom of my data. The only problem is my
data is dynamic. One day it might end on row 1038, another day it might end
on row 1152.

Anyone have VBA code that can help me do this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying formula to the bottom of a range

set rng = range(cells(1,"L"),cells(rows.count,"L").End(xlup) )
rng.offset(0,1).Formula = "=Sum(A1:C1)"

make the formula relative to the first cell in your range and use absolute
and relative addressing as appropriate.

if you already have it in M1 for example, then it would be
set rng = range(cells(1,"L"),cells(rows.count,"L").End(xlup) )
rng.offset(0,1).Formula = Range("M1").formula

--
Regards,
Tom Ogilvy



"jeremy nickels" <jeremy wrote in message
...
I'm trying to create a macro that copies a formula in a column down to the
bottom of a range.

For example, I have data in columns A - L. In column M, I want to create

a
formula and copy it down to the bottom of my data. The only problem is my
data is dynamic. One day it might end on row 1038, another day it might

end
on row 1152.

Anyone have VBA code that can help me do this?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Copying formula to the bottom of a range

thanks Tom, that worked like a charm.

"Tom Ogilvy" wrote:

set rng = range(cells(1,"L"),cells(rows.count,"L").End(xlup) )
rng.offset(0,1).Formula = "=Sum(A1:C1)"

make the formula relative to the first cell in your range and use absolute
and relative addressing as appropriate.

if you already have it in M1 for example, then it would be
set rng = range(cells(1,"L"),cells(rows.count,"L").End(xlup) )
rng.offset(0,1).Formula = Range("M1").formula

--
Regards,
Tom Ogilvy



"jeremy nickels" <jeremy wrote in message
...
I'm trying to create a macro that copies a formula in a column down to the
bottom of a range.

For example, I have data in columns A - L. In column M, I want to create

a
formula and copy it down to the bottom of my data. The only problem is my
data is dynamic. One day it might end on row 1038, another day it might

end
on row 1152.

Anyone have VBA code that can help me do this?




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
COPYING OFFSET FORMULA WITHOUT THE DATA RANGE CHANGING-DESPERATE SHELL Excel Worksheet Functions 5 August 10th 08 02:00 AM
Copying a formula that contains a range of cell rows Anita D Excel Discussion (Misc queries) 4 January 17th 07 10:00 PM
Problem copying formula to range of cells Bob DePass Setting up and Configuration of Excel 0 July 22nd 05 02:09 AM
Copying array formula to a range of cells... Dennis G. Excel Programming 7 January 4th 05 09:43 PM
How to: Add blank row at bottom of range Brad Clarke Excel Programming 2 November 30th 03 10:20 PM


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