Hi all,
I have this simple code (in a Module) that currently references "A2" & "A3" for either "buy" or "sell". Instead I want it to use the OptionButton for either true or false to determine if it is a buy or sell.
I don't want the OptionButton to put a value in a cell to determine if it is true or false (hope this makes sense) example "if optionbutton1 = true then range x = 1 etc" then use this to determine if is a buy or sell.
I am really stuck on how to do this.
Cheers,
O
Sub test()
Dim x As Double
Dim y As Double
Dim strOrder1 As String
Dim strOrder2 As String
strOrder1 = Range("a2").Value
strOrder2 = Range("a3").Value
If strOrder1 = "buy" Then
x = Range("d2").Value * -1
Else
If strOrder1 = "sell" Then x = Range("c2").Value
End If
If strOrder2 = "buy" Then
y = Range("d3").Value * -1
Else
If strOrder2 = "sell" Then y = Range("c3").Value
End If
Range("e2") = x + y
End Sub
I have this simple code (in a Module) that currently references "A2" & "A3" for either "buy" or "sell". Instead I want it to use the OptionButton for either true or false to determine if it is a buy or sell.
I don't want the OptionButton to put a value in a cell to determine if it is true or false (hope this makes sense) example "if optionbutton1 = true then range x = 1 etc" then use this to determine if is a buy or sell.
I am really stuck on how to do this.
Cheers,
O
Sub test()
Dim x As Double
Dim y As Double
Dim strOrder1 As String
Dim strOrder2 As String
strOrder1 = Range("a2").Value
strOrder2 = Range("a3").Value
If strOrder1 = "buy" Then
x = Range("d2").Value * -1
Else
If strOrder1 = "sell" Then x = Range("c2").Value
End If
If strOrder2 = "buy" Then
y = Range("d3").Value * -1
Else
If strOrder2 = "sell" Then y = Range("c3").Value
End If
Range("e2") = x + y
End Sub
Last edited: