W
Wamme
Hi,
I'm working on a UDF that makes a calculation based on 2 cell values and
returns it outcome. I coded a UDF that works perfectly while using it on 1
cell at a time, but failes when dragging it over multiple cells.
Now, the 2 cells are always the same (A1 ,A2) but their values are variabel
and defined as arguments in the functioncall.
So before the UDF performs the calculation, the 2 cells have to be updated
by the argumentvalues. (Through the use of 2 extra functions:
A1=UpdateValue1() and A2=UpdateValue2())
After some examining I found that the 2 cells only updates once at then end
of the dragging operation:
evaluate UDF in D4
evaluate UDF in D5
....
evaluate UDF in D20
update CellValue A1
update CellValue A2
The Desired processflow would be:
evaluate UDF in D4
update CellValue A1
update CellValue A2
evaluate UDF in D5
update CellValue A1
update CellValue A2
....
evaluate UDF in D20
update CellValue A1
update CellValue A2
Can someone help plz? Use a wait/break or an event?
As an example I simplified the calculation as a sum of the two Cell values.
(The desired calculation is more complex)
Public UpdateValue1 As Integer
Public UpdateValue2 As Integer
Function setValues(Value1 As Integer, Value2 As Integer)
Application.Volatile True
UpdateValue1 = Value1
UpdateValue2 = Value2
setValues = Range("A1").Value + Range("A2").Value
End Function
Function updateCell1() As Integer
Application.Volatile True
updateCell1 = UpdateValue1
End Function
Function updateCell2() As Integer
Application.Volatile True
updateCell2 = UpdateValue2
End Function
I'm working on a UDF that makes a calculation based on 2 cell values and
returns it outcome. I coded a UDF that works perfectly while using it on 1
cell at a time, but failes when dragging it over multiple cells.
Now, the 2 cells are always the same (A1 ,A2) but their values are variabel
and defined as arguments in the functioncall.
So before the UDF performs the calculation, the 2 cells have to be updated
by the argumentvalues. (Through the use of 2 extra functions:
A1=UpdateValue1() and A2=UpdateValue2())
After some examining I found that the 2 cells only updates once at then end
of the dragging operation:
evaluate UDF in D4
evaluate UDF in D5
....
evaluate UDF in D20
update CellValue A1
update CellValue A2
The Desired processflow would be:
evaluate UDF in D4
update CellValue A1
update CellValue A2
evaluate UDF in D5
update CellValue A1
update CellValue A2
....
evaluate UDF in D20
update CellValue A1
update CellValue A2
Can someone help plz? Use a wait/break or an event?
As an example I simplified the calculation as a sum of the two Cell values.
(The desired calculation is more complex)
Public UpdateValue1 As Integer
Public UpdateValue2 As Integer
Function setValues(Value1 As Integer, Value2 As Integer)
Application.Volatile True
UpdateValue1 = Value1
UpdateValue2 = Value2
setValues = Range("A1").Value + Range("A2").Value
End Function
Function updateCell1() As Integer
Application.Volatile True
updateCell1 = UpdateValue1
End Function
Function updateCell2() As Integer
Application.Volatile True
updateCell2 = UpdateValue2
End Function