excel - ListObject Table Row Count -
i have excel table 1 header row , 1 data body row. want count data body rows. when i'm trying check how many rows table has with
set myworksheet= activeworkbook.worksheets("sheet1") set mytable= myworksheet.listobjects("table1") countrows = mytable.listrows.count
countrows
contains 0
. if has 2 or more rows, gives right row number. why 0 1 row ans best way count rows or there better ones?
edit:
found out whats causing problem. use lines clear table before fill again:
if tblchart.listrows.count >= 1 mytable.databodyrange.delete end if
after operation table looks described it. without , modifying table described table worked. why causing problem?
the listobject property looking .databodyrange
.
dim myworksheet worksheet, mytable listobject, countrows long set myworksheet = activeworkbook.worksheets("sheet1") set mytable = myworksheet.listobjects("table1") countrows = mytable.databodyrange.rows.count debug.print countrows
a comprehensive list of listobject properties available at: listobject interface.
Comments
Post a Comment