Hi,
I have an Excel Table with an add and remove row button. Currently when these buttons are pressed the Check box is left in limbo. It doesn't copy down or get removed. Is there a way to add to my code that will add or remove the check boxes respectfully when the row is adjusted?
I have an Excel Table with an add and remove row button. Currently when these buttons are pressed the Check box is left in limbo. It doesn't copy down or get removed. Is there a way to add to my code that will add or remove the check boxes respectfully when the row is adjusted?
VBA Code:
'Add New Row to Table Individual Labor
Sub AddRowToTable_Equip_List()
'Declare Variables
Dim oSheetName As Worksheet
Dim sTableName As String
Dim loTable As ListObject
' Turn off Background Noise
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'Define Variable
sTableName = "Equip_List"
'Define WorkSheet object
Set oSheetName = Sheets("Equip List")
'Define Table Object
Set loTable = oSheetName.ListObjects(sTableName)
'Add New row to the table
loTable.ListRows.Add
' Turn Back On Background Noise
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
'Remove Last Row from Table Individual Labor
Sub DeleteLastRow_Equip_List()
' Turn off Background Noise
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim Tbl As ListObject
Set Tbl = ActiveSheet.ListObjects("Equip_List")
' If table is down to last row do not delete Row
If Tbl.DataBodyRange.Rows.Count = 1 Then Exit Sub
'If table has data in the description column do not delete row
Range("Equip_List[Equipment_Type]").Select
Selection.Cells(Selection.Rows.Count, 1).Select
If IsEmpty(Selection) = False Then
MsgBox "Row cannot be removed when Equipment_Type column is populated.", vbExclamation
Exit Sub
End If
Set Tbl = Nothing
' Delete Row
With ActiveSheet.ListObjects("Equip_List").DataBodyRange
ans = .Rows.Count
.Rows(ans).delete
End With
' Turn Back On Background Noise
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub