ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Filldown only with Formula (https://www.excelbanter.com/excel-programming/358208-macro-filldown-only-formula.html)

Ben Noall

Macro Filldown only with Formula
 
Hi,

A new at the macro programming and am trying to produce a macro that
fillsdown formula on my spreadsheet but keeps the formatting. This is the
code that I have currently but it does not keep the format of the cells.

ActiveSheet.Range("V7").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-20]:RC[-2])"
ActiveSheet.Range("V7:V10").Select
Selection.FillDown
ActiveSheet.Range("V31").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-20]:RC[-2])"
ActiveSheet.Range("V31:V39").Select
Selection.FillDown

Any help would be greatly appreciated.

Thanks,

Ben

Tom Ogilvy

Macro Filldown only with Formula
 
Range("V7:V10,V31:V39").FormulaR1C1 = "=SUM(RC[-20]:RC[-2])"

alone should do what you want.



--
Regards,
Tom Ogilvy


"Ben Noall" wrote:

Hi,

A new at the macro programming and am trying to produce a macro that
fillsdown formula on my spreadsheet but keeps the formatting. This is the
code that I have currently but it does not keep the format of the cells.

ActiveSheet.Range("V7").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-20]:RC[-2])"
ActiveSheet.Range("V7:V10").Select
Selection.FillDown
ActiveSheet.Range("V31").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-20]:RC[-2])"
ActiveSheet.Range("V31:V39").Select
Selection.FillDown

Any help would be greatly appreciated.

Thanks,

Ben



All times are GMT +1. The time now is 11:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com