Make VBA Enter Formula into cell rather than calculation

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?
 
J

Jacob Skaria

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top