WORKSHEET MULTIPLE CHECKBOXES ALTERNATIVE (SOLVED)

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Here is some code you might find useful. It uses column(s) of cells as tickboxes that toggle when double-clicked. It solves several problems - such as having to set up and align numerous controls, which, if from the Controls Toolbox could contain bugs.

Format the column(s) as Wingdings font etc.. The code goes into the worksheet code module (right click sheet tab/'View Code')

It is easy to use a formula in a worksheet like
=IF(A1="",B1,C1)
or write code that looks for non-blank cells in the ranges for further automation.


Code:
'------------------------------------------------------
'- WORKSHEET CHECKBOX ALTERNATIVE
'- ADDS OR REMOVES TICK IN A CELL. Font = Wingdings.
'- This example uses columns B and E.
'- and rows 10 to 38
'- Brian Baulsom October 2000
'------------------------------------------------------
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, _
        Cancel As Boolean)
    Dim MyTick As String
    MyTick = Chr(252)
    TopRow = 10
    BottomRow = 38
    '-
    If (ActiveCell.Column = 2 Or ActiveCell.Column = 5) _
        And ActiveCell.Row >= TopRow _
        And ActiveCell.Row <= BottomRow Then
        If ActiveCell = "" Then
            ActiveCell.Value = MyTick
        Else
            ActiveCell.Value = ""
        End If
        ActiveCell.Offset(1, 0).Select
    Else
        MsgBox ("Cannot tick here.")
    End If
End Sub
'-------------------------------------------------------------------------

Code:
'==================================================
'- CHECK FOR TICKS IN COLUMN B
'- PRINT APPROPRIATE WORKSHEET (name in column C)
'==================================================
Sub CheckForTicks()
    Dim Toprow As Long
    Dim BottomRow As Long
    Dim MySheet As String
    '------------------------------
    Toprow = 10
    BottomRow = 38
    For r = Toprow To BottomRow
        If ActiveSheet.Cells(r, 2).Value <> "" Then
            MySheet = ActiveSheet.Cells(r, 3).Value
            WorkSheets(MySheet).PrintOut
        End If
    Next
        
End Sub
'====================================================
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Great code, I am running it on some computers and getting errors due to the microsoft datagrid add-in not being installed. Any way around this????

Hmmm, it may not actually be that.....tools, preferences on the not working computers showed that add-in missing, but when I disable that add-in on the working comps it still works......:confused now: :)

Thanks :)
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,472
Members
449,087
Latest member
RExcelSearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top