tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
I have a UDF that depends on the value on another sheet:
So in Sheet2, cell B2, I type:
which gives me a value of 20, IF the value in cell A1 of Sheet1 is 1.
The problem is if I change the value in cell A1 of Sheet1, the value in Sheet2, cell B2 is NOT automatically changed.
I have to physically go to cell B2 of Sheet2 and press F2.
What can I do so that by changing the value in cell A1 of Sheet1, the value in cell B2 of Sheet2 AUTOMATICALLY updates?
Thanks
Code:
Option Explicit
Function MyFn(val As Double) As Double
If Sheet1.Cells(1, 1).Value = 1 Then
MyFn = val + 10
Else
MyFn = val + 20
End If
End Function
So in Sheet2, cell B2, I type:
Code:
myfn(10)
which gives me a value of 20, IF the value in cell A1 of Sheet1 is 1.
The problem is if I change the value in cell A1 of Sheet1, the value in Sheet2, cell B2 is NOT automatically changed.
I have to physically go to cell B2 of Sheet2 and press F2.
What can I do so that by changing the value in cell A1 of Sheet1, the value in cell B2 of Sheet2 AUTOMATICALLY updates?
Thanks