![]() |
Simple VB code
Hi,
Im trying to write a simple macro with a checkbox, so when i click a checkbox a number is added to another number. So for example when i select a checkbox i want the number 5 to be added to a number in another cell on my spreadsheet. Thankyou |
Simple VB code
Place a checkbox from the control toolbox toolbar
double click on the checkbox and it will take you to the Click event Private Sub CheckBox1_Click() End Sub You can put your code he Private Sub CheckBox1_Click() if not isnumeric(Range("A1").Value) then exit sub if CheckBox1.Value = True then Range("A1").Value = Range("A1").Value + 5 else Range("A1").Value = Range("A1").Value - 5 end if End Sub Adjust the code to perform the functionality you actually require. No go back to excel and in the control toolbox toolbar, make sure the button in the upper left hand corner is not depressed (take you out of design mode). -- Regards, Tom Ogilvy "cjupiter" wrote in message ... Hi, Im trying to write a simple macro with a checkbox, so when i click a checkbox a number is added to another number. So for example when i select a checkbox i want the number 5 to be added to a number in another cell on my spreadsheet. Thankyou |
Simple VB code
Try this If CheckBox1.Value = True Then Range("A1").Value = (Range("a1").Value + Range("a2").Value) End If First place a checkbox called checkbox1 in your sheet, double click on the box and insert this snip of code. You can change the range values to suit or change the range prior to the equals sign to place the result in another cell. Regards Kev *** Sent via Developersdex http://www.developersdex.com *** |
Simple VB code
Thanks guys. Much helpful :)
"cjupiter" wrote: Hi, Im trying to write a simple macro with a checkbox, so when i click a checkbox a number is added to another number. So for example when i select a checkbox i want the number 5 to be added to a number in another cell on my spreadsheet. Thankyou |
All times are GMT +1. The time now is 06:48 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com