dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,352
- Office Version
- 365
- 2016
- Platform
- Windows
I have a button that once pressed, adds rows to a table. How do I ensure each newly added row is .69cm height?
VBA Code:
Sub Addlines()
Application.EnableEvents = False
'ActiveSheet.Unprotect Password:="CSSadmin"
Dim ws As Worksheet, x As Long, tbl As ListObject, n As Long
On Error GoTo cancelled:
n = InputBox("How many lines would you like to add ?")
Set ws = ActiveSheet
Set tbl = ws.ListObjects("CSS_quote")
'add 5 rows
For x = 1 To n
'add a row at the end of the table
tbl.ListRows.Add
' ActiveSheet.ListObjects("CSS_quote").DataBodyRange.Columns(12).Value = 1 - 0.1 * ActiveSheet.chkIncrease.Value
Range("A:A").NumberFormat = "dd/mm/yyyy"
Next x
tbl.Range.Cells(tbl.ListRows.Count - n + 2, 1).Select
'ActiveSheet.Protect Password:="CSSadmin"
Application.EnableEvents = True
cancelled:
Exit Sub
End Sub