if a checkbox is checked then...

T

tkw

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
 
J

JLGWhiz

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
 
D

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top