I need to loop through checkboxes in excel spreadsheet and if checked do something depending on which checkbox. What I would really like is to be able to determine which row and column any checkbox in on. Any help appreciated.
Dim cBox As CheckBox
Dim LRow As Integer
Dim LCol As Integer
Dim LName As String
Dim cellToUpdate As String
Dim cellToMoveTo As String
Dim EMailTextCell As String
Dim EmailText As String
Dim recips As String
Dim cc As String
LName = Application.Caller
Set cBox = ActiveSheet.CheckBoxes(LName)
'Find row that checkbox resides in
LRow = cBox.TopLeftCell.Row
LCol = cBox.TopLeftCell.Column
If cBox.Value > 0 Then
ActiveSheet.Range(cellToUpdate).Value = Now
If ActiveSheet.Range(cellToEmail).Value <> "" Then
GetEmailRecips ActiveSheet.Range(cellToEmail).Value, recips, cc
EmailText = ActiveSheet.Range(EMailTextCell).Value
GenerelEmail recips, cc, EmailText
End If
Else
ActiveSheet.Range(cellToUpdate).Value = Null
End If
Range(cellToMoveTo).Select
End Sub
I have a spreadsheet with checkboxes in a column. I needed to know which checkbox was selected and then pick up details from the adjacent columns if checked. I didn't want to write seperate macros for each checkbox, so I just associate this macro with all the checkboxes and once I know the row I can pick up the details I want.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.