ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if a checkbox is checked then... (https://www.excelbanter.com/excel-programming/434689-if-checkbox-checked-then.html)

tkw

if a checkbox is checked then...
 
I am trying to write a code that will allow me to multiple one range by .15
- IF THE CHECKBOX IS CHECKED - and place the sum in another range. If not
checked then it will equal 0


If chkEligable.Value = True Then

Range ("Retirement") will equal .15 times Range ("Annual_Salary")

Else

Range("Retirement").Value = 0
Thanks


JLGWhiz[_2_]

if a checkbox is checked then...
 
I assume the checkbox is on a sheet. Richt click on
the sheet tab and click "View Code" to open the sheet
code module. Then copy and past the code into the code
window. Also assumed you named the checkbox as shown.


Private Sub chkEligable_Click()
If chkEligable.Value = True Then
Range("Retirement") = 0.15*Range("Annual_Salary").Value
Else
Range("Retirement") = 0
End Sub



"tkw" wrote in message
...
I am trying to write a code that will allow me to multiple one range by .15
- IF THE CHECKBOX IS CHECKED - and place the sum in another range. If not
checked then it will equal 0


If chkEligable.Value = True Then

Range ("Retirement") will equal .15 times Range ("Annual_Salary")

Else

Range("Retirement").Value = 0
Thanks




Dave Peterson

if a checkbox is checked then...
 
with worksheets("Somesheetname")
If chkEligable.Value = True Then
.Range("Retirement").value = 0.15 * .Range("Annual_Salary").value
else
.range("Retirement").value = 0
end if
end with

I assumed that both the ranges are on the same sheet (named somesheetname).

And this doesn't check for any non-numerical data, either.

tkw wrote:

I am trying to write a code that will allow me to multiple one range by .15
- IF THE CHECKBOX IS CHECKED - and place the sum in another range. If not
checked then it will equal 0

If chkEligable.Value = True Then

Range ("Retirement") will equal .15 times Range ("Annual_Salary")

Else

Range("Retirement").Value = 0
Thanks


--

Dave Peterson


All times are GMT +1. The time now is 01:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com