Vba Get last used row of a Table

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
19,621
Office Version
  1. 2021
Platform
  1. Windows
I use this line of code to find last used row in column "A"
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

But how do I do this to find last used row in column "A" Table1
Or last used row of Table1
 
I thought my question was a simple one.
I want to know what is the last used row in "Table1"

Thanks for the link I have looked at that but no where does it mention how to know what row in a Table is the last used row.

Hi,

I assume Table1 is actually a Table. Referencing Tables is supposed to be done with Listobjects.
Take a look at this: https://www.thespreadsheetguru.com/blog/2014/6/20/the-vba-guide-to-listobject-excel-tables

Are you looking for the row number within the sheet or the Table?

For the Row within the Table you can use: ActiveSheet.ListObjects("Table1").ListRows.Count
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
But then the user said Sheet "Preapprovalas" had a table in it.
So I want to paste the row into the Tables 1st empty row.
Are you aware that you copy the whole row from one sheet to another. As you told in your first post there is a table in sheet "Preapprovals". You have to ensure that the date to be copied has the same number of columns or less as the table has.

To insert a row at the end of a Tables DataRange you can use the following code:
Code:
With ActiveSheet.ListObjects("Table1").ListRows.Add(alwaysinsert:=True)
    .Range.Cells(1, 1).Value = 1 'Inserts a 1 into the rows first column.
End With
 
Upvote 0
I use this line of code to find last used row in column "A"
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

But how do I do this to find last used row in column "A" Table1
Or last used row of Table1
Old post but better late than never:


To find last row in table:

VBA Code:
Sub Find_Last_Row()
'----------------------------------------------------------------
' Assign a variable to hold our table named "Table1"
'----------------------------------------------------------------
Dim tbl1 As ListObject
Dim ws As Worksheet

Set ws = ThisWorkbook.Worksheets("Sheet1")

Set tbl1 = ws.ListObjects("Table1")

Dim lrow As Long
'----------------------------------------------------------------
' Find last row, if table has header is in row 1 of worksheet
'----------------------------------------------------------------
lrow = tbl1.Range.Rows.Count
'----------------------------------------------------------------
' Find last row, if table header has is not in row 1 of worksheet
'----------------------------------------------------------------
lrow = tbl1.Range.Rows(tbl1.Range.Rows.Count).Row
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top