Variable in Active.FormulaLocal

VictorA73 -  
f894009 Posted messages 17417 Registration date   Status Membre Last intervention   -
Hello,

I have a little issue: in one column, I want to sum the price associated only with the rows where the value of another column is "in Process"
the formula works well when I manually input the ranges, but I would like to set up variable ranges defined beforehand
That's when it bugs

What works:

Cells(127, 11).Select
ActiveCell.FormulaLocal = "=SUMIF(P12:P266; ""In Process""; I12:I266)"

What does not work:

Dim Plage As Range
Dim Prix As Range

Set Plage = Range(Cells(12, 16), Cells(266, 16))
Set Prix = Range(Cells(12, 9), Cells(266, 9))

Cells(127, 11).Select
ActiveCell.FormulaLocal = "=SUMIF('" & Plage & "'; ""In Process""; '" & Prix & "')"

Hoping you can help me,

Have a good day

Configuration: Windows / Chrome 64.0.3282.186

1 réponse

f894009 Posted messages 17417 Registration date   Status Membre Last intervention   1 717
 
Hello,

Sub test() RangeAddress = Range(Cells(12, 16), Cells(266, 16)).Address Price = Range(Cells(12, 9), Cells(266, 9)).Address Cells(127, 11).Select ActiveCell.FormulaLocal = "=SUMIF(" & RangeAddress & ";""In Process"";" & Price & ")" End Sub
0