View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sarah H.[_2_] Sarah H.[_2_] is offline
external usenet poster
 
Posts: 48
Default Table column in VBA

Hi, all,

I am writing some VBA code and want to control an Excel 2010
table-object and a column or headers to a column from it with set
abstraction names rather than just using the real name. I'm having
trouble getting it to work.

So I have a table called "Table2". I have a column called "Key" as
the left column of that.

Dim tblTgt As Range

Set tblTgt = [table2] 'workbook scope

Well, that actually works. But then I can't, later,
select a column such as "Key" or a headder row or cell.
It won't work:

Range(TblTgt[[#Headers],["Key"]]).Select
Range(TblTgt[[#Headers],[Key]]).Select
TblTgt[[#Headers],[Key]].Select
TblTgt[[#Headers],["Key"]].Select

and various other variations on that kind of thing won't
work. I have to go back to:

Range("Table2[[#Headers],[Key]]").Select

That works, but it defeats the point of the abstraction
in the code.

Ideas?