ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programmatically calculating formulas for new entries (https://www.excelbanter.com/excel-programming/390373-programmatically-calculating-formulas-new-entries.html)

Carlee

Programmatically calculating formulas for new entries
 
Hi there,

I have a series of data that is imported into specific rows/columns. There
are a number of calculated columns, that for now, i have to copy and paste
down to each new row.

Question: is there a way to have the calculations done with out having to
manually pull them down to each new row?
--
Carlee

Tom Ogilvy

Programmatically calculating formulas for new entries
 
Sub Fillformulas()
Dim rng As Range, lastRow As Long
Dim cell As Range
Set rng = Rows(2).SpecialCells(xlFormulas)
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
If lastRow 2 Then
For Each cell In rng
cell.Offset(1, 0).Resize(Rows.Count - 2, 1).ClearContents
cell.Resize(lastRow - 1, 1).Formula = cell.Formula
Next
End If

End Sub

Might give you some ideas. I have made a lot of assumptions. I assume you
have data starting in A2 with headers in row 1 and your formulas are at least
in row 2. Also, that column 1 can be used to determine the extent of the
data.

If you want to just test it, do it on a copy of your data/workbook.

--
Regards,
Tom Ogilvy


"Carlee" wrote:

Hi there,

I have a series of data that is imported into specific rows/columns. There
are a number of calculated columns, that for now, i have to copy and paste
down to each new row.

Question: is there a way to have the calculations done with out having to
manually pull them down to each new row?
--
Carlee



All times are GMT +1. The time now is 02:51 AM.

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