Private Sub CommandButton1_Click()
Dim lrow As Long
lrow = Cells(65536, "D").End(xlUp).Row
Cells(lrow + 2, "I").Formula = "=sum(I16:I" & lrow & ")"
Cells(lrow + 2, "J").Formula = "=sum(J16:J" & lrow & ")"
Cells(lrow + 2, "K").Formula = "=sum(K16:K" & lrow & ")"
Cells(lrow + 2, "L").Formula = "=sum(L16:L" & lrow & ")"
Cells(lrow + 2, "M").Formula = "=sum(M16:M" & lrow & ")"
Cells(lrow + 2, "N").Formula = "=sum(N16:N" & lrow & ")"
Cells(lrow + 2, "O").Formula = "=sum(O16:O" & lrow & ")"
Cells(lrow + 2, "F") = "Total Hours"
Range("I" & lrow + 2 & ":O" & lrow + 2).Font.Bold = True
Cells(lrow + 2, "F").Font.Bold = True
End Sub
Private Sub ToggleButton1_Click()
If ToggleButton1.Value Then
'Toggle on code
Dim lrow As Long
lrow = Cells(65536, "D").End(xlUp).Row
Cells(lrow + 2, "I").Formula = "=sum(I16:I" & lrow & ")"
Cells(lrow + 2, "J").Formula = "=sum(J16:J" & lrow & ")"
Cells(lrow + 2, "K").Formula = "=sum(K16:K" & lrow & ")"
Cells(lrow + 2, "L").Formula = "=sum(L16:L" & lrow & ")"
Cells(lrow + 2, "M").Formula = "=sum(M16:M" & lrow & ")"
Cells(lrow + 2, "N").Formula = "=sum(N16:N" & lrow & ")"
Cells(lrow + 2, "O").Formula = "=sum(O16:O" & lrow & ")"
Cells(lrow + 2, "F") = "Total Hours"
Range("I" & lrow + 2 & ":O" & lrow + 2).Font.Bold = True
Cells(lrow + 2, "F").Font.Bold = True
Else
'Toggle Off code
Dim lrow As Long
lrow = Cells(65536, "D").End(xlUp).Row
Cells(lrow + 2, "I").Formula = ""
Cells(lrow + 2, "J").Formula = ""
Cells(lrow + 2, "K").Formula = ""
Cells(lrow + 2, "L").Formula = ""
Cells(lrow + 2, "M").Formula = ""
Cells(lrow + 2, "N").Formula = ""
Cells(lrow + 2, "O").Formula = ""
Cells(lrow + 2, "F") = ""
Range("I" & lrow + 2 & ":O" & lrow + 2).Font.Bold = False
Cells(lrow + 2, "F").Font.Bold = False
End If
End Sub
Private Sub ToggleButton1_Click()
Dim lrow As Long
If ToggleButton1.Value Then
'Toggle on code
lrow = Cells(65536, "D").End(xlUp).Row
Cells(lrow + 2, "I").Formula = "=sum(I16:I" & lrow & ")"
Cells(lrow + 2, "J").Formula = "=sum(J16:J" & lrow & ")"
Cells(lrow + 2, "K").Formula = "=sum(K16:K" & lrow & ")"
Cells(lrow + 2, "L").Formula = "=sum(L16:L" & lrow & ")"
Cells(lrow + 2, "M").Formula = "=sum(M16:M" & lrow & ")"
Cells(lrow + 2, "N").Formula = "=sum(N16:N" & lrow & ")"
Cells(lrow + 2, "O").Formula = "=sum(O16:O" & lrow & ")"
Cells(lrow + 2, "F") = "Total Hours"
Range("I" & lrow + 2 & ":O" & lrow + 2).Font.Bold = True
Cells(lrow + 2, "F").Font.Bold = True
Else
'Toggle Off code
lrow = Cells(65536, "D").End(xlUp).Row
Cells(lrow + 2, "I").Formula = ""
Cells(lrow + 2, "J").Formula = ""
Cells(lrow + 2, "K").Formula = ""
Cells(lrow + 2, "L").Formula = ""
Cells(lrow + 2, "M").Formula = ""
Cells(lrow + 2, "N").Formula = ""
Cells(lrow + 2, "O").Formula = ""
Cells(lrow + 2, "F") = ""
Range("I" & lrow + 2 & ":O" & lrow + 2).Font.Bold = False
Cells(lrow + 2, "F").Font.Bold = False
End If
End Sub
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Excel Formula | 5 | 46 | |
Delete all empty columns using VBA | 7 | 42 | |
which one of the last argument of YEARFARCis correct to use | 5 | 23 | |
Excel VBA - Constants | 4 | 16 |
Join the community of 500,000 technology professionals and ask your questions.