[Dba-office] Excet Table with VBA

Salakhetdinov Shamil mcp2004 at mail.ru
Fri Dec 18 07:38:13 CST 2015


 Hi Susan --

Here it's:

Option Explicit
Public Sub testAddXlTableRow()
' https://msdn.microsoft.com/en-us/library/office/ff196248(v=office.15).aspx
Dim lst As ListObject
Set lst = ThisWorkbook.Worksheets("DataValidation").ListObjects("Table1")
' add an empty row and seed its cells' values with
' this added row index
Dim listRow As listRow
Dim cellIndex As Integer
Set listRow = lst.ListRows.Add(AlwaysInsert:=True)
For cellIndex = 1 To listRow.Range.Cells.Count
listRow.Range.Cells(cellIndex) = listRow.Index
Next cellIndex
End Sub
-- Shamil

>Thursday, December 17, 2015 5:48 PM -05:00 from "Susan Harkins" <ssharkins at gmail.com>:
>
>I can add a new row to an Excel Table using the following line of code:
>
> 
>
> 
>ThisWorkbook.Worksheets("DataValidation").ListObjects("Table1").ListRows.Add
>AlwaysInsert:=True
>
> 
>
>But for the life of me I can't figure out how to add a value to the new row!
>I've read all day and I can find all kind of articles on the above - but
>nothing on how to add a value to that new row. 
>
> 
>
>Susan H. 
>
>_______________________________________________
>Dba-office mailing list
>Dba-office at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-office



More information about the Dba-office mailing list