autofill cell value based on combined selection of checkbox and option button

dss28

Board Regular
Joined
Sep 3, 2020
Messages
165
Office Version
  1. 2007
Platform
  1. Windows
In my user form I want to perform mathematical equation based on selection of one of option button (from 4 option buttons) and a check box.

The purpose of selecting one of four option buttons is to perform mathematical calculation based one of four equations.

The checkbox selection defines whether a mathematical calculation is to be performed or not. it uses the value in TextBox115, TextBox130 and TextBox160.

After entering a value in TextBox115, the result of mathematical calculation based on selection of option button and checkbox should appear in TextBox8

If only option button is selected without checkbox selection then it should perform multiplication of value in TextBox115 and TextBox114 and display result in TextBox8.

the code i am trying is enclosed.



other issue i am seriously facing in this form is that of not enough memory to display the form. Dont know if it is because the form contains many textboxes , command buttons etc. total of more than about 240 items.

please guide



VBA Code:
Private Sub TextBox115_Change()

    If UserForm38.OptionButton1.Value = True Then            'equation 1
    If UserForm38.CheckBox1.Value = True Then
    UserForm38.TextBox8.Value = Format((UserForm38.TextBox115.Value * 0.01) * UserForm38.TextBox114.Value / (UserForm38.TextBox130.Value * (100 - UserForm38.TextBox160.Value)), "0.000")
'
'Else
''End
End If


    If UserForm38.OptionButton2.Value = True Then               equation 2
    If UserForm38.CheckBox1.Value = True Then
    UserForm38.TextBox8.Value = Format((UserForm38.TextBox115.Value * 0.002) * UserForm38.TextBox114.Value / (UserForm38.TextBox130.Value * (100 - UserForm38.TextBox160.Value)), "0.000")

' Else
' End
End If


    If UserForm38.OptionButton3.Value = True Then               equation 3
    If UserForm38.CheckBox1.Value = True Then
    UserForm38.TextBox8.Value = Format((UserForm38.TextBox115.Value * 0.001) * UserForm38.TextBox114.Value / (UserForm38.TextBox130.Value * (100 - UserForm38.TextBox160.Value)), "0.000")

' Else
' End
End If


    If UserForm38.OptionButton1.Value = True Then               ' equation 4
    If UserForm38.CheckBox1.Value = True Then
    UserForm38.TextBox8.Value = Format((UserForm38.TextBox115.Value * 0.1) * UserForm38.TextBox114.Value / (UserForm38.TextBox130.Value * (100 - UserForm38.TextBox160.Value)), "0.000")

' Else
End If
   
        If UserForm38.OptionButton1.Value = True Then               ' equation 5      
        UserForm38.TextBox8.Value = Format((UserForm38.TextBox115.Value * UserForm38.TextBox114.Value *0.01), "0.000")  ' no checkbox selected


End If
End If
End If
End If
End If

End

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,155
Messages
6,170,403
Members
452,325
Latest member
BlahQz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top