stucamps
Board Regular
- Joined
- Jul 3, 2003
- Messages
- 114
I am wanting to change the formula reference in a cell dependent on an OptionButton Selected.
Currently the formula in the spreadsheet is:
=IF(AND(ISNUMBER(D12),ISNUMBER(D22)),+D12-D22,"-")
but if I select an option button then I want to change the D12 to D13, as I want to select a different row for analysis, and I have tried the following code:
I even tried to change the formula in VBA to
ThisWorkbook.Sheets(2).Range("d22").FormulaArray = "=IF(AND(ISNUMBER(R13C4), ISNUMBER(R22C4)),+R13C4-R22C4," - ")"
Please note that D22 does not need to change
using the RxCx method but to no avail.
Any ideas on how I can change this?
Thanks
Stuart
Currently the formula in the spreadsheet is:
=IF(AND(ISNUMBER(D12),ISNUMBER(D22)),+D12-D22,"-")
but if I select an option button then I want to change the D12 to D13, as I want to select a different row for analysis, and I have tried the following code:
Code:
Private Sub cmdConfirm_Click()
If OptionButton1.Value = True Then
ThisWorkbook.Sheets(2).Range("d22").FormulaArray = "=IF(AND(ISNUMBER(D12), ISNUMBER(D22)),+D12-D22," - ")"
End If
End Sub
ThisWorkbook.Sheets(2).Range("d22").FormulaArray = "=IF(AND(ISNUMBER(R13C4), ISNUMBER(R22C4)),+R13C4-R22C4," - ")"
Please note that D22 does not need to change
using the RxCx method but to no avail.
Any ideas on how I can change this?
Thanks
Stuart