On sheet 'Work' I have a table:
Set tbl = Work.ListObjects("CaseData")
lastWork = tbl.Range.Rows.Count
Now I am trying to fill a range within the table. I am able to do that without referring to the table this way:
Work.Range("A2:A" & lastWork) = 10
However, the following does not work:
tbl.Range("A2:A" & lastWork).Value = 10
I am getting an error: Invalid procedure call or argument. How would I fill a column within a table? And is it possible to do that referring to the column name?
If you want to refer to the column by name:
tbl.ListColumns("ColumnName").DataBodyRange.Value = 10
You can also refer to it by index:
tbl.ListColumns(1).DataBodyRange.Value = 10