ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add to an Existing formula in a Cell using VBA (https://www.excelbanter.com/excel-programming/436734-add-existing-formula-cell-using-vba.html)

sgltaylor

Add to an Existing formula in a Cell using VBA
 
Hi,

I am trying to figure out how to do the following:

Assume you have a formula like sum (A1:A5) in cell A6.
What I need to do is add a sumproduct formula to the existing formula
using vba.
For example, the formula in cell A6 will be updated to sum(A1:A5)/
SUMPRODUCT((C4:C8=B1)*(D4:D8=B2))

Any ideas or suggestions.

Thanks,

Steve

Don Guillett

Add to an Existing formula in a Cell using VBA
 
Basic idea. Modify to suit

Sub addtoformulawithvba()
With ActiveCell
MsgBox .Formula
..Formula = .Formula & "+d2"
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"sgltaylor" wrote in message
...
Hi,

I am trying to figure out how to do the following:

Assume you have a formula like sum (A1:A5) in cell A6.
What I need to do is add a sumproduct formula to the existing formula
using vba.
For example, the formula in cell A6 will be updated to sum(A1:A5)/
SUMPRODUCT((C4:C8=B1)*(D4:D8=B2))

Any ideas or suggestions.

Thanks,

Steve




All times are GMT +1. The time now is 01:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com