I have a table that contains header row, data body and totals row. I want to find the last row in the last column (in this case) of the data body and I want to have the value of the totals row.
I can get the last row and column value (135) by this VBA
Sub Target()
Dim ws1 As Worksheet
Set ws1 = Worksheets("Nordics")
Dim ams As Long
Dim Target As Variant
ans = ws1.ListObjects("TableNordics").DataBodyRange.Rows.Count
Target = ws1.ListObjects("TableNordics").DataBodyRange(ans, 8).Value
End Sub
But, I can not get something simmilar to work for the Totals row (note, message box is just to see if the value works
Sub Table_Lastrow()
Dim ams As Long
ans = ActiveSheet.ListObjects("TableNordics").TotalsRowRange.Value
MsgBox "Last row in Table is " & ans
End Sub
When I get this to work, I would like to change the Worksheet and Table name to be variable, eg. I will have the names in Cell A1 And A2, I have tried a couple of things for the first formula, but I can not get it to work.
