Hello,

I have made a serialize list for multiple parts. Each button represents a part number with a cell. When I click on the toggle button it crosses that cell with a red "X" and adds to a counter in a particular cell and does the opposite with I unclick the toggle button. The sheet has 1000 toggle buttons and the code gets repetitive. Here's the code for each toggle button:

Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
Togglebutton1.ForeColor = &HFF&
Togglebutton1.BackColor = &H80000015
Range("A5").Borders(xlDiagonalDown).LineStyle = XlLineStyle.xlContinous
Range("A5").Borders(xlDiagonalUp).LineStyle = XlLineStyle.xlContinous
Range("A5").Borders(xlDiagonalDown).Color = vbRed
Range("A5").Borders(xlDiagonalUp).Color = vbRed
Range("B55").Value = Range("B55").Value +1
End If
If ToggleButton1.Value = False Then
Togglebutton1.ForeColor = &H80000012
Togglebutton1.BackColor = &H8000000F
Range("A5").Borders(xlDiagonalDown).LineStyle = XlLineStyle.xlLineStyleNone
Range("A5").Borders(xlDiagonalUp).LineStyle = XlLineStyle.xlLineStyleNone
Range("B55").Value = Range("B55".Value -1
End if
End Sub


My question is can I simplify this code where I can use self made functions or is there an easier way to to achieve what I'm trying to do?

Any help will be greatly appreciated.