bumbum2812
New Member
- Joined
- Sep 7, 2020
- Messages
- 26
- Office Version
- 365
- Platform
- Windows
Hi experts, i'm having a vba code to add a new row to my table, if my first row is blank, it need to run twice to add the second row, if my first row is not blank it only need one time.
Thank you in advance.
Thank you in advance.
VBA Code:
Sub AddRow()
Dim pswStr As String
pswStr = "@"
On Error Resume Next
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:=pswStr
Dim ws As Worksheet
Set ws = ActiveSheet
Dim tbl As ListObject
Set tbl = ws.ListObjects("TB_ReOpen")
'add a row at the end of the table
tbl.ListRows.Add
ActiveSheet.Protect Password:=pswStr
End Sub