I got nr of request to be action. Each request can have any nr of items, generally it's between 5-40 items per request. Column A consist name of request. I want to add in one column checkbox for each item and in next column checkbox for all items from that request. So that user can select can select any individual item or whole request.
I've managed to add checkboxes, but then hit issue with names for check boxes and can't move forward.
On next step I wanted to assign macro to checkboxes for whole request, so once clicked each item from request will have the same value as Select All checkbox.
code is somehow working for first item only. most likely because names for other items don't match but it could be something else - as form controls are some new thing for me
thanks for reading and suggestion
I've managed to add checkboxes, but then hit issue with names for check boxes and can't move forward.
Code:
Sub woff_checkbox()
Dim lr As Integer
lr = Cells(Rows.Count, "A").End(xlUp).Row
For i = 4 To lr
ActiveSheet.CheckBoxes.Add(Cells(i, 7).Left, Cells(i, 7).Top, 100, 15).Select
With Selection
.Caption = Cells(i, 1)
.name = Cells(i, 1)
End With
Next
For i = 4 To lr
If Cells(i, 1) = Cells(i - 1, 1) Then
'
Else
ActiveSheet.CheckBoxes.Add(Cells(i, 8).Left, Cells(i, 8).Top, 100, 15).Select
With Selection
.Caption = "All " & Cells(i, 1)
.name = "All " & Cells(i, 1)
End With
End If
Next
End Sub
On next step I wanted to assign macro to checkboxes for whole request, so once clicked each item from request will have the same value as Select All checkbox.
Code:
Sub SelectAll_Click()
Dim my_name As String
Dim cb As CheckBox
Dim cb_value As Long
my_name = Application.Caller
cb_value = ActiveSheet.Shapes(my_name).OLEFormat.Object.value
For Each cb In ActiveSheet.CheckBoxes
If cb_value = xlOn Then
If cb.name = Mid(my_name, 5) Then
cb.value = xlOn
End If
Else
If cb.name = Mid(my_name, 5) Then
cb.value = xlOff
End If
End If
Next
End Sub
code is somehow working for first item only. most likely because names for other items don't match but it could be something else - as form controls are some new thing for me
thanks for reading and suggestion