Make VBA Enter Formula into cell rather than calculation

  • Thread starter Thread starter Benjamin
  • Start date Start date
B

Benjamin

How would I make say Cell C1's value be "A1+B1",
rather than the caluculation of A1+B1 i.e. 4
Don't want the number 4 to show in the formula bar.
Because I'd like to autofill the formula and not the number 4 down the
column of a
similiar calculation.

I'd like to learn how to code something like that. Then I can apply it to
several different macros I have.

I want VBA to enter the formula into a cell rather than the resulting answer..
is this possible?
 
With numbers in colA and B the below code will assign the formula A+B in ColC
.. Try with dummy data in ColA and ColB...

Sub Macro()

Dim rngData As Range
Set rngData = Range("C1:C" & Cells(Rows.Count, "A").End(xlUp).Row)
rngData.Formula = "=A1+B1"

End Sub

If this post helps click Yes
 
Back
Top