Visual Basic Check Boxes

emily2309

Board Regular
Joined
Nov 17, 2009
Messages
51
I will explain my spreadsheet first to let you know what I am doing.

I am creating a scheduling program for my company. I want the spreadsheet to feedback to me what shifts are available for overtime depending on who is on holiday. I have set it up to show everyones shifts when they are not on holiday. Everyone's shift has an IF statement, which is linked to another sheet. This IF statement basically says that if the colleague is on holiday, do not put their shift here. This means it will be left blank and i will know that they are on holiday.

Right..
I have created a user form, where i will enter who is on holiday. I have a combo box to select the colleague, and then below that i have check boxes to select which days they are on holiday. What i need help with is how to code the check boxes so that when they are clicked, they send data to the spreadsheet to say which one is clicked. It also needs to link to the colleagues name.
Basically, I am going to need to paste into the spreadsheet "on holiday" for each colleague and each day they are on holiday.

I hope this makes sense!

Thanks :)
 
Maybe something like this?

Code:
Private Sub CheckBox1_Click()
    If CheckBox1.Value = True Then
        Select Case ComboBox1.SelText
            Case "Joe"
                Range("A1").Value = "On Holiday"
            Case "Moe"
                Range("A2").Value = "On Holiday"
            Case "Mary"
                Range("A3").Value = "On Holiday"
            Case Else
                ' no name selected
                Exit Sub
        End Select
    End If
End Sub
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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