I create a column of Checkboxes (FORM) at the end of rows of data as follows (WORKS FINE):
This function creates a border marker next to the first cell in the row when the corresponding box is checked (WORKS FINE):
Here's the problem:
After a SORT is performed, the data (including the checkboxes) is shifted around, but NOT the corresponding borders (Excel's SORT does not move cell borders)! So, I am trying to recreate the border markers (which were created with the above function) based on the current status of my 120 Checkboxes!
This is what I have:
Help please! Project due...
Code:
Sub DoCheckboxes()
For Each cell In Range("O3:O60,O66:O123")
With Sheets(1).CheckBoxes.Add(cell.Left + 2, cell.Top, 15, cell.Height)
.LinkedCell = cell.Offset(, 0).Address(External:=True)
.Interior.ColorIndex = xlClear
.Caption = ""
.OnAction = "Chk_Click"
End With
Next
End Sub
Code:
Sub Chk_Click()
Dim chk As CheckBox: Set chk = ActiveSheet.CheckBoxes(Application.Caller)
If chk.Value = xlOn Then
Cells(chk.TopLeftCell.Row, 1).Borders(xlEdgeRight).LineStyle = xlDouble
Else
Cells(chk.TopLeftCell.Row, 1).Borders(xlEdgeRight).LineStyle = xlDot
End If
End Sub
After a SORT is performed, the data (including the checkboxes) is shifted around, but NOT the corresponding borders (Excel's SORT does not move cell borders)! So, I am trying to recreate the border markers (which were created with the above function) based on the current status of my 120 Checkboxes!
This is what I have:
Code:
Sub UpdateMarker()
Dim i As Integer
Dim chk As CheckBox: Set chk = ActiveSheet.CheckBoxes(Application.Caller) '? not sure if this is right
For i = 3 To 123
If i < 61 Or i > 65 Then
If chk.Value = "TRUE" Then '? need to check state of current checkbox
Cells(i, 1).Borders(xlEdgeRight).LineStyle = xlDouble
Else
Cells(i, 1).Borders(xlEdgeRight).LineStyle = xlDot
End If
End If
Next
End Sub