B
BG Lad
Functionality: To Remove an OLE check box in the row when the user deletes a
row.
This is my current attempt. I get an error message "Can't enter break mode
at this time".
The CheckBox is not linked, it is for visual and print only. There are
remmed statements from previous attempts. Any ideas on this one?
'** Snipped ******************
Dim rowcount As Long
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Err_Worksheet_Change
Dim llCanDeleteTheBox As Boolean
Dim lcCheckBoxToDelete As String
'Application.EnableEvents = False 'should be part of Change macro
If IsEmpty(rowcount) Then
'* First time through ... *'
Else
If ActiveSheet.UsedRange.Rows.Count = rowcount - 1 Then
'* A row was deleted *'
lcCheckBoxToDelete = "CheckBox" + Trim(Str(ActiveSheet.Range("A"
+ Trim(Str(Target.Row))).Value))
For Each Obj In ThisWorkbook.ActiveSheet.OLEObjects
'* Find the Relative Checkbox *'
Stop
If Obj.Name = lcCheckBoxToDelete Then
Stop
'Obj.Delete
llCanDeleteTheBox = True
'lcCheckBoxToDelete = Obj.Name
'ThisWorkbook.ActiveSheet.OLEObjects(Obj.Name).Delete
Exit For
End If
Next
End If
End If
If llCanDeleteTheBox Then
Stop
'* Delete the Check Box *'
ThisWorkbook.ActiveSheet.OLEObjects(lcCheckBoxToDelete).Delete
End If
rowcount = ActiveSheet.UsedRange.Rows.Count
'** End of SNIPPED *****************
row.
This is my current attempt. I get an error message "Can't enter break mode
at this time".
The CheckBox is not linked, it is for visual and print only. There are
remmed statements from previous attempts. Any ideas on this one?
'** Snipped ******************
Dim rowcount As Long
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Err_Worksheet_Change
Dim llCanDeleteTheBox As Boolean
Dim lcCheckBoxToDelete As String
'Application.EnableEvents = False 'should be part of Change macro
If IsEmpty(rowcount) Then
'* First time through ... *'
Else
If ActiveSheet.UsedRange.Rows.Count = rowcount - 1 Then
'* A row was deleted *'
lcCheckBoxToDelete = "CheckBox" + Trim(Str(ActiveSheet.Range("A"
+ Trim(Str(Target.Row))).Value))
For Each Obj In ThisWorkbook.ActiveSheet.OLEObjects
'* Find the Relative Checkbox *'
Stop
If Obj.Name = lcCheckBoxToDelete Then
Stop
'Obj.Delete
llCanDeleteTheBox = True
'lcCheckBoxToDelete = Obj.Name
'ThisWorkbook.ActiveSheet.OLEObjects(Obj.Name).Delete
Exit For
End If
Next
End If
End If
If llCanDeleteTheBox Then
Stop
'* Delete the Check Box *'
ThisWorkbook.ActiveSheet.OLEObjects(lcCheckBoxToDelete).Delete
End If
rowcount = ActiveSheet.UsedRange.Rows.Count
'** End of SNIPPED *****************