![]() |
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. |
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 |
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 |
All times are GMT +1. The time now is 12:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com