Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add value when checkbox is ticked


Can anyone please tell me how to put a checkbox in an Excel Spead Shee
and when it is checked to add a value to a field?

Thanks in advance

--
emel2
-----------------------------------------------------------------------
emel24's Profile: http://www.excelforum.com/member.php...fo&userid=2000
View this thread: http://www.excelforum.com/showthread.php?threadid=55679

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Add value when checkbox is ticked

Depending what you require, but something like:
Private Sub CheckBox1_Click()
Const ExtraValue As Long = 25
If CheckBox1.Value = True Then
Range("A1").Value = Range("A1").Value + ExtraValue
Else
'Decide what you do here
End If
End Sub

NickHK

"emel24" wrote in
message ...

Can anyone please tell me how to put a checkbox in an Excel Spead Sheet
and when it is checked to add a value to a field?

Thanks in advance.


--
emel24
------------------------------------------------------------------------
emel24's Profile:

http://www.excelforum.com/member.php...o&userid=20004
View this thread: http://www.excelforum.com/showthread...hreadid=556792



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add value when checkbox is ticked


Can you please advise where to enter this?
Is this a Macro?

Thanks in advance.


--
emel24
------------------------------------------------------------------------
emel24's Profile: http://www.excelforum.com/member.php...o&userid=20004
View this thread: http://www.excelforum.com/showthread...hreadid=556792

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Add value when checkbox is ticked

After you have added your combo box to the worksheet, view its code and this
is one of its events.
Private Sub CheckBox1_Click()

I assume you are using the check box from the Controls toolbox, not from
Forms.

NickHK

"emel24" wrote in
message ...

Can you please advise where to enter this?
Is this a Macro?

Thanks in advance.


--
emel24
------------------------------------------------------------------------
emel24's Profile:

http://www.excelforum.com/member.php...o&userid=20004
View this thread: http://www.excelforum.com/showthread...hreadid=556792



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add value when checkbox is ticked


Yes, I wasn't using the Controls toolbox to create the checkbox. Your
formular works now.

However I am trying to do the following:
When checkbox1 is ticked I want to show 5% of the sum of a column in
another field. And when checkbox2 is ticked I want to show 10% of the
sum in another field.

For example: A7 = 500
When checkbox1 is ticked add 5%
Show value in A8 (being 25) if not ticked don't show a value
When checkbox 2 is ticket add 10%
Show value in A9 (being 50) if not ticked don't show a value

Thanks for your help! :-)


--
emel24
------------------------------------------------------------------------
emel24's Profile: http://www.excelforum.com/member.php...o&userid=20004
View this thread: http://www.excelforum.com/showthread...hreadid=556792



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add value when checkbox is ticked


I have just noticed that when I tick the box it does the 5% however if I
untick it again it doesn't set it back to 0.
How can I do it, that whenever it is ticked or unticked to change the
value?


--
emel24
------------------------------------------------------------------------
emel24's Profile: http://www.excelforum.com/member.php...o&userid=20004
View this thread: http://www.excelforum.com/showthread...hreadid=556792

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Add value when checkbox is ticked

Just edit the previous code slightly:
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
Range("A8").Value = Range("A7").Value * 1.05
Else
Range("A8").Value = 0 'Or "" if you want nothing to show
End If
End Sub

'This is effectively the same as the code above, FALSE=0, TRUE= -1
Private Sub CheckBox2_Click()
Range("A9").Value = Range("A7").Value * 1.1 * (CheckBox2.Value = True) * -1
End Sub

NickHK

"emel24" wrote in
message ...

Yes, I wasn't using the Controls toolbox to create the checkbox. Your
formular works now.

However I am trying to do the following:
When checkbox1 is ticked I want to show 5% of the sum of a column in
another field. And when checkbox2 is ticked I want to show 10% of the
sum in another field.

For example: A7 = 500
When checkbox1 is ticked add 5%
Show value in A8 (being 25) if not ticked don't show a value
When checkbox 2 is ticket add 10%
Show value in A9 (being 50) if not ticked don't show a value

Thanks for your help! :-)


--
emel24
------------------------------------------------------------------------
emel24's Profile:

http://www.excelforum.com/member.php...o&userid=20004
View this thread: http://www.excelforum.com/showthread...hreadid=556792



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Allowing only 1 check box to be ticked Nadia Excel Discussion (Misc queries) 12 November 28th 09 10:55 PM
CheckBox Ticked, ComboBoxBox visible? hoyos Excel Discussion (Misc queries) 2 November 17th 09 07:48 PM
Add contents of two cells when a tick box is ticked Andy Excel Worksheet Functions 2 September 19th 08 05:38 AM
get a list of ticked add-in Dan Excel Worksheet Functions 2 June 19th 07 08:58 PM
VBA for put cell C2 in overstrike/black when B2 checkbox is ticked? StargateFan[_3_] Excel Programming 1 February 14th 05 02:28 PM


All times are GMT +1. The time now is 12:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"