I reckon the best way is to only add a checkbox the row that is highlighted when a row inserted (rather than deleting them all and replacing. I am trying to reference the inserted row but can't quite get the syntax
this doesn't work
With Rows(ActiveCell.Row).CheckBoxes.Add(cell.Left, _
cell.Top, cell.Width, cell.Height)
.LinkedCell = cell.Offset(, 0).Address(External:=T)
.Interior.ColorIndex = 37
.Caption = ""
End With
I suggest trying to adjust the worksheet change sub to not reference the add and delete subs in module 7 but to just add a checkbox to the inserted row
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call TagCellManager(Target)
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim CurCel As Range, CurRow As Range
Dim TagCel As Range, TagRow As Range
Dim NxtCel As Range, NxtRow As Range
Dim r As Range, ws As Worksheet
Set CurCel = Target.Item(1, 1)
Set CurRow = Cells(CurCel.Row, 1)
Set TagCel = Cells(CurCel.Row + Target.Rows.Count, CurCel.Column)
Set TagRow = Cells(CurCel.Row + Target.Rows.Count, 1)
Set NxtCel = TagCel.Offset(Target.Rows.Count, 0)
Set NxtRow = TagRow.Offset(Target.Rows.Count, 0)
If TagCel.ID <> "" And TagRow.ID <> "" Then
ElseIf NxtCel.ID <> "" Or NxtRow.ID <> "" Then
With Rows(ActiveCell.Row).CheckBoxes.Add(cell.Left, _
cell.Top, cell.Width, cell.Height)
.LinkedCell = cell.Offset(, 0).Address(External:=T)
.Interior.ColorIndex = 37
.Caption = ""
End With
'Call Module7.DelCheckBox
'Call Module7.AddCheckBox
'Call Module2.SelectAllCheckBoxes
Set Target = Range(NxtCel.ID)
Call TagCellManager(Target)
ElseIf CurCel.ID <> "" Or CurRow.ID <> "" Then
'MsgBox "row deleted"
'Call Module7.DelCheckBox
'Call Module7.AddCheckBox
'Call Module2.SelectAllCheckBoxes
Set Target = Range(CurCel.ID)
Call TagCellManager(Target)
End If
End Sub
let me know how you get on
Bookmarks