Inserting a Table Using LastRow

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
946
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I'm trying to Insert a Table using LastRow, instead of just using Row 5,000.

For LastRow (which is working) I have:
VBA Code:
LastRow = Range("I:I").Cells.Find("*", _
        SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        MsgBox "The Last Non-Blank Row Is " & LastRow

For Inserting my Table (which is not working) I have:
Code:
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1" & LastRow), , xlYes).Name = _
"Table1"
Range("Table1[#All]").Select
/CODE]

How am I using LastRow wrong?
Thanks for the help
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try
VBA Code:
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:A" & LastRow), , xlYes).Name = "Table1"
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,665
Members
449,114
Latest member
aides

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