check boxes

G

gareth

I have several check boxes on a sheet. I want to check
these boxes and return a 'Y' if it has been selected and
a 'N' if it hasn't.

Thanks in advance.

gareth
 
T

Tom Ogilvy

What kind of checkboxes. ActiveX from the control toolbox toolbar or excel
checkboxes from the forms toolbar. When do you want them to return Y or N?
When the control is checked. If so, then without code, link the checkboxes
to the cell over which they are located and which will contain True or
False. Then in another cell, put in a formula like =if(b9,"Y","N") where
B9 is the linked cell.

Otherwise you would need to not linke the checkbox and use event code to
place the Y or N in the cell.
 
G

gareth

From the Forms toolbar.

I want to return a 'Y' or a 'N' in a macro. Should I link
the cells and do it that way or is there another way?

gareth
 
T

Tom Ogilvy

Public Sub Btn_click()
Dim sName As String, cbx As CheckBox
Dim rng As Range
sName = Application.Caller
Set cbx = ActiveSheet.CheckBoxes(sName)
Set rng = cbx.TopLeftCell.Offset(0, -1)
If cbx = xlOn Then
rng.Value = "Y"
Else
rng.Value = "N"
End If
End Sub

Assign this to all your checkboxes. It puts Y or N to the cell to the left
of the cell with the checkbox over it.

Or adjust it to fit you needs.
 
Top