How can i get this macro to run everytime i change value in column 8 in a table.
Dim ws As Worksheet
Dim table As ListObject
Dim tblRows As ListRows
Dim tblRow As ListRow
Set ws = Sheet1
Set table = ws.ListObjects("Table1")
Set tblRows = table.ListRows
For Each tblRow In tblRows
If table.DataBodyRange(tblRow.Index, 8) = "Defect" Then
table.DataBodyRange(tblRow.Index, 10) = "New test"
ElseIf table.DataBodyRange(tblRow.Index, 8) = "Ok" Then
table.DataBodyRange(tblRow.Index, 10) = table.DataBodyRange(tblRow.Index, 6) + 366
ElseIf table.DataBodyRange(tblRow.Index, 8) = "" Then
table.DataBodyRange(tblRow.Index, 10) = ""
End If
Next tblRow
Dim ws As Worksheet
Dim table As ListObject
Dim tblRows As ListRows
Dim tblRow As ListRow
Set ws = Sheet1
Set table = ws.ListObjects("Table1")
Set tblRows = table.ListRows
For Each tblRow In tblRows
If table.DataBodyRange(tblRow.Index, 8) = "Defect" Then
table.DataBodyRange(tblRow.Index, 10) = "New test"
ElseIf table.DataBodyRange(tblRow.Index, 8) = "Ok" Then
table.DataBodyRange(tblRow.Index, 10) = table.DataBodyRange(tblRow.Index, 6) + 366
ElseIf table.DataBodyRange(tblRow.Index, 8) = "" Then
table.DataBodyRange(tblRow.Index, 10) = ""
End If
Next tblRow