View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
colin_e[_2_] colin_e[_2_] is offline
external usenet poster
 
Posts: 2
Default Structured Table Refs in VBA

I'm confused about the relationship between tables (using structured
references) and ranges.

I can work on individual cells from a table column, similar to working with
a range, using-

Dim oSh As Worksheet
Set oSh = ActiveSheet
Dim r As Range

For Each r In oSh.Range("MyRange[ColumnName]")
r.Value = 10
Next

But if I try to create a range object from a table, using any of-

r = oSh.Range("MyRange")
r = oSh.Range("MyRange[#Data]")
r = oSh.Range("MyRange[ rowvariable, [ColumnName]]")

I think I am failing to see some basic principle here. I see lots of
reference material on how structured table refs work in the Excel UI. Can
someone point me to something simialr, or even just some working examples,
for VBA code?