View Single Post
 
Old 04-17-2022, 04:14 AM
soroush.kalantari soroush.kalantari is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Jun 2021
Posts: 115
soroush.kalantari is on a distinguished road
Default How to write a macro for inserting a formula in an Excel cell such that its components be p

I have written a macro, in a part of it, I want to insert a formula in an Excel cell which its components are parameters not texts. But when running the code, the excel encounters an error saying “Run time error 1004,Application defined or Object defined error". Can anybody Guides me on this issue? (the part of Macro with this problem is as follow. For example, When I am in C5, when running the macro, I expect to see the formula =C5+C6 in C1 )

Sub insertformula()
cell01 = ActiveCell.Address(0, 0)
ActiveCell.Offset(1, 0).Activate

cell02 = ActiveCell.Address(0, 0)

range("c1").Value = "=&cell01& + &cell02&"
End Sub

Last edited by soroush.kalantari; 04-17-2022 at 07:59 PM.
Reply With Quote