Check Boxes
Is there a way that I can insert check boxes into an excel spreadsheet?
|
Check Boxes
Hi
The following code will place a series of checkboxes alongside values in another column, in Column G in this example. Sub CreateCheckBoxes() On Error Resume Next Dim c As Range, myRange As Range, lastcell As Long If Application.ScreenUpdating = True _ Then Application.ScreenUpdating = False lastcell = Cells(Rows.Count, 6).End(xlUp).Row Set myRange = Range("G1:G" & lastcell) For Each c In myRange.Cells ActiveSheet.CheckBoxes.Add(c.Left, _ c.Top, c.Width, c.Height).Select With Selection .LinkedCell = c.Address .Characters.Text = "" .Name = "Check" & c.Address .Display3DShading = True End With Next myRange.Select Selection.ColumnWidth = 2.15 Application.ScreenUpdating = True End Sub After ticking, just check whether value of cell in G is TRUE or FALSE You can copy the code I posted and paste it into your Visual Basic Editor (VBE) in a Standard Module located in your project (workbook). Shortcut keys would be .. Alt + F11 (open VBE) Ctrl + R (open Project Explorer) Select file on left If no modules exist: Insert | Module Paste code in Module If modules exist: Double click desired module Paste code in Module Add code as desired -- Regards Roger Govier "adyer" wrote in message ... Is there a way that I can insert check boxes into an excel spreadsheet? |
Check Boxes
Hi Roger,
I was playing around with your code, is there a way to ensure that the checkBoxes won't group together. if I put a formula in column H like =If(G1=True,2,1) and copied this down to the end of the checkbox row after this the boxes became grouped |
All times are GMT +1. The time now is 09:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com