What is the best way to iterate through the contents of each cell in a table and retrieve/store its value.
With my current approach, I'm unable to obtain set the value of a table in my variable val
Sample Table:
Set ws = ActiveSheet
ws.Name = "sheet1"
Set tbl = ws.ListObjects("tblBor")
Application.Calculation = xlCalculationManual
ws.Calculate
With tbl.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("tblBor[ID]"), SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
Set rng = Range(tbl)
rows = tbl.Range.rows.Count
Columns = tbl.Range.Columns.Count
For iter = 1 To rows
For col = 1 To Columns
'Iterate through each row by each column
'val = tbl.DataBodyRange(iter, col).Value
Next col
Next iter

Valis a built-in function. Maybe use a different name. Also you have a typoColumns = tbl.Rable.Columns.Count, what'sRable? Finally, you need to be consistent - you're using bothtbl.Rangeandtbl.DataBodyRange.tbl.Rangeincludes the header row. Not sure you want that. You might also want to consider a different name forrowsandColumns.tbl.ListRows(iter).Range(1, col).Valuetbl.DataBodyRange.Cells(iter, col).Range.Cells(row, col)is that it's retrieving objects in an object collection by index, which is inefficient. Object collections want to be iterated with aFor Eachloop.