formulas

  • Thread starter Thread starter Max_Venezia
  • Start date Start date
M

Max_Venezia

I wanted to repeat a formula contained into an initial cell in another
group of cells.
I selected the initial formula in this manner:

ActiveCell.select
x=Selection.formula

then I selected a group of cells
and I wanted to repeat the same formula contained in the initial cell
into these cells

I wrote:
SelectedRange.formula=x

In this way the furmulas I find in the new cells are not equal to the
initial one but
they change from cell to cell according to the position.
If I want to repeat exactly the initial formula in these new cells
regardless of the cell positions what kind of instruction I have to
use?

Thank you in advance.
Max
 
Max,

You need to change the original formula to an absolute reference. For
example, if the formula is =A1+B1, change it to =$A$1+$B$1

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
The fact is that the original formula has not absolute reference and
it is correct. i want to transfer the same formula into another cell.
for example if the cell a1 contains the formula =c1+b2
I want that all the destination cells have the same formula (=c1+b1)
without the absolute reference.
 
How about:

Sub CopyFormula()

Dim cell As Range
Dim strFormula As String

strFormula = ActiveSheet.Range("A1").Formula
' change the range to whatever your destination range is
For Each cell In ActiveSheet.Range("A3:A5")
cell.Formula = strFormula
Next cell

Set cell = Nothing

End Sub
 
Back
Top