Search notes:

Excel Object Model: add rows to a ListObject

The following example tries to demonstrate how rows can be added to a `listObject object with Visual Basic for Applications.
option explicit

sub main() ' {

    dim rngHeader as range
    set rngHeader = range(cells(2,2), cells(2,4))
    rngHeader.value = array("col one", "col two", "col three")

    dim table as listObject
    set table = activeSheet.listObjects.add(   _
       sourceType             := xlSrcRange  , _
       source                 := rngHeader   , _
       xlListObjectHasHeaders := xlYes)

    table.listRows.add.range.value = array("foo", 42, #2020-03-05#)
    table.listRows.add.range.value = array("bar", 99, #2017-10-17#)
    table.listRows.add.range.value = array("baz",  5, #2018-03-21#)

end sub ' }
Github repository about-MS-Office-object-model, path: /Excel/ListObject/add-rows.bas
After running this simple program, the following list table is produced:

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1759268566, '216.73.216.128', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Excel/Object-Model/ListObject/add-rows(57): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78