Posts

Showing posts from December, 2023

Working With Tables In Excel (VBA)

From   Excel: Working with Tables (VBA) (jkp-ads.com) Working With Tables In Excel (VBA) Introduction In  Working with Tables in Excel  I promised to add a page about working with those tables in VBA too. Well, here you go. It's a ListObject! On the VBA side there seems to be nothing new about Tables. They are addressed as ListObjects, a collection that was introduced with Excel 2003. But there are significant changes to this part of the object model and I am only going to touch on the basic parts here. Creating a table Converting a range to a table is simple enough:  Sub CreateTable()     ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$1:$D$16"), , xlYes).Name = _         "Table1"     ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight2" End Sub Table formatting is determined by TableStyles. A collection of objects which are a member of the Workbook object. This gives rise to some od...