#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default CheckBox

I would like to add a checkbox in each row that has a specific value in
column "B" (i.e. "Mark") and then link that check box to another column in
the same row. Can this be done with a loop so that I do not have to manually
do this? Thanks for the help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CheckBox


Hello Herd,

Yes it can be done and placed into a loop...
______________________________

Sub AddCheckBoxes()

'Add A Forms CheckBox

Dim Cell As Range
Dim Col As String
Dim LinkCol
Dim R As Long
Dim Value

Col = "B"
Value = "Mark"
LinkCol = "D"

For R = 1 To ActiveSheet.Cells(Rows.Count, Col).Row
Set Cell = ActiveSheet.Cells(R, Col)
If Cell.Value = Value Then
With ActiveSheet.Shapes
..AddFormControl xlCheckBox, Cell.Left, Cell.Top, Cell.Width,
Cell.Height
End With

Shapes(Shapes.Count).ControlFormat.LinkedCell = Cell.(R,
LinkCol).Address
End If
Next R

End Sub
______________________________

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=509609

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

One mo

Option Explicit
Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("a1:a50").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = "" 'or whatever you want
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With
Next myCell
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

I used the cell under the checkbox as the linked cell. But I gave it a custom
format of ;;;. You can see the value in the formula bar, but it looks empty
when you look at the worksheet.



Herd wrote:

I would like to add a checkbox in each row that has a specific value in
column "B" (i.e. "Mark") and then link that check box to another column in
the same row. Can this be done with a loop so that I do not have to manually
do this? Thanks for the help.


--

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
How to have Checkbox A uncheck with checked Checkbox B Texas Aggie Excel Discussion (Misc queries) 3 July 20th 07 10:58 PM
checkbox on form reset from checkbox on sheet raw[_12_] Excel Programming 1 December 3rd 05 05:08 AM
Checkbox help Steve_K Excel Discussion (Misc queries) 3 November 29th 05 10:33 AM
Checkbox Susan Hayes Excel Programming 1 March 31st 05 11:42 PM
CheckBox Susan Hayes Excel Programming 1 March 23rd 05 02:36 PM


All times are GMT +1. The time now is 10:42 PM.

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

About Us

"It's about Microsoft Excel"