lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
Why I need cells.formula when I can do it without cells.formula as following:
Code:
Sub cell_formula()
    Workbooks(1).Worksheets(1).Cells(1, 1).Value = "=sum(c1+c2)"
End Sub
Thank you so much.
 
To print a string preceded by the = sign that Excel interprets as a formula, yes, either .formula or .value will work. Sometimes, however, you may wish to distinguish between types:


Excel 2010
C
13
24
3
4
57
Sheet3
Cell Formulas
RangeFormula
C5=SUM(C1+C2)


Code:
Sub formulavsvalue()
[c7] = Left([c5].Formula, 1)
[c8] = Left([c5].Value, 1)
End Sub


Excel 2010
C
13
24
3
4
57
6
7=
87
Sheet3
Cell Formulas
RangeFormula
C5=SUM(C1+C2)
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,216,116
Messages
6,128,926
Members
449,479
Latest member
nana abanyin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top