Macro to Resize table with dynamic last row - not working - HELP!!

daithiboy

Board Regular
Joined
Jul 1, 2016
Messages
77
Hi folks,

This is probably very easy and amateurish, but, I am looking for a way to resize a table with a dynamic last row. When I record a macro of a resize with a set range I get:

Code:
Sub resizetable222()


    ActiveSheet.ListObjects("Table5").Resize Range("$A$5:$I$94")
    Range("I94").Select
End Sub

when i try and change the resize range to
Code:
("$A$5:lastcell)
it doesn't work i.e

Code:
Sub resizetable()


Dim lcell As Long
Dim lrow As Long
    
    lrow = ThisWorkbook.Sheets("Filter").Cells(Rows.Count, 1).End(xlUp).Row
    MsgBox lrow
    
    lastcell = Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Select
        
    Sheets("Filter").ListObjects("Table5").Resize Range($A$5, lastcell)
    
    
End Sub

As you can see I was messing around the lastrow also but could not get it to work either.

Any thoughts would be very much appreciated.

Many thanks in advance,
Dave
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try replacing:
Code:
Range("$A$5:$I$94")
with:
Code:
Range("$A$5:$I$" & lrow)
 
Upvote 0

Forum statistics

Threads
1,215,206
Messages
6,123,636
Members
449,109
Latest member
Sebas8956

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