Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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 ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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

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
need a simple code Peter McCaul Excel Programming 1 August 11th 04 08:13 PM
Simple Code Help DaveB[_2_] Excel Programming 1 June 25th 04 06:21 PM
simple code gavmer[_5_] Excel Programming 4 May 19th 04 03:32 AM
Help With Very Simple Code pauluk[_17_] Excel Programming 7 April 8th 04 10:45 AM
Some simple code WiReLaD Excel Programming 1 October 30th 03 07:11 PM


All times are GMT +1. The time now is 02:15 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"