apply macro to last row in a table

redink20

New Member
Joined
Jun 9, 2015
Messages
2
I have a macro that runs based on a row and column range, for example the macro occurs if someone selects a cell in column 5-8 and row 3-48. However, these cells are in a table called "Tbl_Results" and as users may want to extend the number of rows in the table, so I would like this macro to extend as well. With the current code, even by added a row in the table, the macro stops at row 48. How would I indicate the number of rows to encompass all rows in "Tbl_Results"? I don't believe the column numbers will be changing.

Currently, it is written as:
If Target.Column >= 5 And Target.Column <= 8 And Target.Row >= 3 And Target.Row <= 48

Thank you.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I figured it out - I changed the code of line to read:
If Target.Row >= 3 And Target.Column >= 5 And Target.Column <= 8 And Target.Row <= Range("A1").CurrentRegion.Rows.Count
 
Upvote 0

Forum statistics

Threads
1,215,815
Messages
6,127,035
Members
449,355
Latest member
g wiggle

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