Hi,
I have a problem.
I was thinking about my macro, and i need it to go like this:
User puts a value o percentage loss that he would like to define and then macro change this value in the calcualted field.
i dont really know how to write it down. i have something like this so far.
I would like to look like this:
User puts a value that of index that he wants (10% makes 0.9/1/1.1, 20% makes 0.8/1/1.2 in the following formula) and macro change the formula in the calculated field.
Sub calculate_field()
Dim w As Worksheet, p As PivotTable
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
For Each w In ThisWorkbook.Worksheets
For Each p In w.PivotTables
p.CalculatedFields("Index").StandardFormula="=IF(Sales<>production,IF(sales=0,2,IF(production=0,-2,IF(sales/production<0.9,2,IF(sales/production<1,1,IF(sales/production>1.1,-2,-1))))))"
p.Update
Next
Next
End Sub
Now i get wrong numbers of argument or invalid property assignment :/
Bookmarks