Hi,
I'm creating an Excel 2010 workbook for processing a bunch of scientific data dumped from an instrument. So far I've been able to code for creating a table from the dumped data. Now I would like to be able to add a formula to a column to calculate an area percentage--it just divides the value from the current row of the "Area" column by the total of the "Area" column. If I hard-code in the name of the table (in this case Tbl_071-0272.D), it works fine.
However, I would like to be able to store the table name in a variable so I can cycle through many data sets. When I try this, I get error 1004, though.
So this works:
And this doesn't (note that DataTbl.Name = "Tbl_071-0272.D"):
Am I doing something wrong or am I up against an Excel 2010 limitation?
Many thanks,
Byron
I'm creating an Excel 2010 workbook for processing a bunch of scientific data dumped from an instrument. So far I've been able to code for creating a table from the dumped data. Now I would like to be able to add a formula to a column to calculate an area percentage--it just divides the value from the current row of the "Area" column by the total of the "Area" column. If I hard-code in the name of the table (in this case Tbl_071-0272.D), it works fine.
However, I would like to be able to store the table name in a variable so I can cycle through many data sets. When I try this, I get error 1004, though.
So this works:
Code:
DataTbl.ListColumns(7).DataBodyRange.Cells(1).Formula = _
"=[@Area]/Tbl_071-0272.D[[#Totals],[Area]]"
And this doesn't (note that DataTbl.Name = "Tbl_071-0272.D"):
Code:
DataTbl.ListColumns(7).DataBodyRange.Cells(1).Formula = _
"=[@Area]/" & DataTbl.Name & "[[#Totals],[Area]]"
Am I doing something wrong or am I up against an Excel 2010 limitation?
Many thanks,
Byron