Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Checkbox procedures

I have tried several different things and I don't know alot about checkbox
procedures.
This is what I want to do. I have a checkbox in a worksheet lets say at
cell B3. I want the cell at B4 to contain the word "YES" when the checkbox
is ticked and blank when the box is not ticked.
Could someone please write me the code that will do what I am wanting to do,
then I can expand on it as I need to.

Thanks,
Russ
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checkbox procedures


Russ,
A disclaimer first, I am not an expert in VBA like some on this site,
but this code works for me.

Private Sub CheckBox1_Click()
Dim i As Boolean
Dim rng1 As Range

Application.DisplayAlerts = False
i = CheckBox1.Value
Set rng1 = Range("$B$4")
If i = True Then
rng1.Value = “YES”
Else
rng1.Value = “”
End If
Application.DisplayAlerts = True

End Sub

HTH


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=572416

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Checkbox procedures

How about dropping the code and just using a linked cell and then point at that
linked cell.

I dropped a checkbox from the Forms toolbar onto a worksheet.
I rightclicked on that checkbox and chose format control
Then on the control tab, I added an address for the Cell Link. (I used B3, but
you could use any cell you want.)

Then in B4, I put this formula:
=if(b3=true,"YES","")

And I gave B3 a custom format of:
;;;
(3 semicolons, so I couldn't see the True/False in the worksheet.)

=========
If you really, really want code (I wouldn't!)...

You could assign this macro to the checkbox:

Option Explicit
Sub testme01()

Dim myCBX As CheckBox

Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)

If myCBX.Value = xlOn Then
activesheet.range("B4").value = "YES"
Else
activesheet.range("B4").clearcontents
End If

End Sub

rbbbbeee wrote:

I have tried several different things and I don't know alot about checkbox
procedures.
This is what I want to do. I have a checkbox in a worksheet lets say at
cell B3. I want the cell at B4 to contain the word "YES" when the checkbox
is ticked and blank when the box is not ticked.
Could someone please write me the code that will do what I am wanting to do,
then I can expand on it as I need to.

Thanks,
Russ


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Checkbox procedures

Thanks Casey!

"Casey" wrote:


Russ,
A disclaimer first, I am not an expert in VBA like some on this site,
but this code works for me.

Private Sub CheckBox1_Click()
Dim i As Boolean
Dim rng1 As Range

Application.DisplayAlerts = False
i = CheckBox1.Value
Set rng1 = Range("$B$4")
If i = True Then
rng1.Value = €œYES€
Else
rng1.Value = €œ€
End If
Application.DisplayAlerts = True

End Sub

HTH


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=572416


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Checkbox procedures

Thanks Dave! I believe that I will just link to another cell as you
suggested. Much easier.


"Dave Peterson" wrote:

How about dropping the code and just using a linked cell and then point at that
linked cell.

I dropped a checkbox from the Forms toolbar onto a worksheet.
I rightclicked on that checkbox and chose format control
Then on the control tab, I added an address for the Cell Link. (I used B3, but
you could use any cell you want.)

Then in B4, I put this formula:
=if(b3=true,"YES","")

And I gave B3 a custom format of:
;;;
(3 semicolons, so I couldn't see the True/False in the worksheet.)

=========
If you really, really want code (I wouldn't!)...

You could assign this macro to the checkbox:

Option Explicit
Sub testme01()

Dim myCBX As CheckBox

Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)

If myCBX.Value = xlOn Then
activesheet.range("B4").value = "YES"
Else
activesheet.range("B4").clearcontents
End If

End Sub

rbbbbeee wrote:

I have tried several different things and I don't know alot about checkbox
procedures.
This is what I want to do. I have a checkbox in a worksheet lets say at
cell B3. I want the cell at B4 to contain the word "YES" when the checkbox
is ticked and blank when the box is not ticked.
Could someone please write me the code that will do what I am wanting to do,
then I can expand on it as I need to.

Thanks,
Russ


--

Dave Peterson

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
Simplifying numerous checkbox procedures into 1 procedure PJ Murph[_2_] Excel Worksheet Functions 2 March 21st 09 09:32 PM
How to have Checkbox A uncheck with checked Checkbox B Texas Aggie Excel Discussion (Misc queries) 3 July 20th 07 10:58 PM
Get VBA procedures from DB Hiran de Silva[_2_] Excel Programming 3 July 4th 06 05:46 PM
How do I link one checkbox to update another checkbox? Mike Excel Programming 3 April 28th 06 02:22 AM
checkbox on form reset from checkbox on sheet raw[_12_] Excel Programming 1 December 3rd 05 05:08 AM


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