VBA - Tables - Select a cell in last row of Data Body Range

Marty Plante

New Member
Joined
Dec 28, 2016
Messages
17
Office Version
  1. 365
Platform
  1. Windows
I'm struggling to find code that takes me to the last row in a table, in a particular column. I use a table for navigation with hyperlinks and when a new component in the workbook is created a row is added to the bottom of an existing table. I want to paste into one particular cell the name of the new item in the workbook. Finding last used row normally isn't a challenge but with tables I'm getting last row with data (don't care) and I want only the last row that code already created. New row - select cell in column X. A few links or advice would be helpful. Thank you!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Can you post the code you currently have.
 
Upvote 0
Public Sub Add_Meal_To_Navigation_Table()

'This is called from another macro. Adds a new row to bottom of table. I would like to select the last cell in the 6th column of the table.

Sheet9.Select

ActiveSheet.ListObjects("Tbl_Navigation_Links").ListRows.Add AlwaysInsert:=True



End Sub
 
Upvote 0
Maybe you can adapt something like this.
VBA Code:
Sub test()
Dim LO As ListObject, LR As Long, LC As Long
Set LO = ActiveSheet.ListObjects(" Tbl_Navigation_Links ")
With LO
    LR = .Range.Rows.Count
    LC = .Range.Columns.Count
    'select the last row in the table
    .Range.Rows(LR).Select
    'select cell at the intersection of the last row and 6th column in the table
    .Range.Cells(LR, 6).Select
End With
End Sub
 
Upvote 0
Ok, how about
VBA Code:
Sub MartyPlante()
   Dim NewRw As ListRow
   Set NewRw = Sheet9.ListObjects("Tbl_Navigation_Links").ListRows.Add(AlwaysInsert:=True)
   NewRw.Range(1, 6).Value = "Abc"
End Sub
 
Upvote 0
Second one gets me there. First one put me on the totals row, sub martyplante works so I can continue build from here. Thanks for the assistance!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

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