RuneDefour
04-05-2023, 07:25 AM
when I press button 2, a row should be added at the bottom of the table. but it doesn't work i keep getting an error message. how else should I do it?
Private Sub CommandButton2_Click()
Dim stockTable As ListObject
Set stockTable = ActiveSheet.ListObjects("stock2")
stockTable.ListRows.Add
With stockTable.ListRows(stockTable.ListRows.Count).Range
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeRight).Weight = xlThin
End With
End Sub
Private Sub CommandButton2_Click()
Dim stockTable As ListObject
Set stockTable = ActiveSheet.ListObjects("stock2")
stockTable.ListRows.Add
With stockTable.ListRows(stockTable.ListRows.Count).Range
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeRight).Weight = xlThin
End With
End Sub