Search code examples
excelvbarangehiddenlistobject

excel vba listobject HeaderRowsRange


I am working with list objects in excel and there is one thing that puzzles me: according to this and many other sites I visited the following line of code is a range:

mytable.headerRowRange("nameofColumn")

mytable being a listobject of a particular sheet.

what I wand to do is hide that column

but this would not work:

mytable.headerRowRange("nameofColumn").EntireColumn.Hidden=True

Why?

the error is: Invalid procedure call or argument.

thanks.


Solution

  • mytable.ListColumns("ID").Range.EntireColumn.Hidden = True