Find last row in filtered range

robertvdb

Active Member
Joined
Jan 10, 2021
Messages
327
Office Version
  1. 2016
Platform
  1. Windows
I have a list with cities in USA and Canada. Now I need some VBA code to identify the last row in this list (row 23 in this case), however AFTER the filter has been applied.

So if I filter the list on "USA", the result of the VBA should still be row 23, not row 18.

Can anybody help ? See the enclosed screen capture.
 

Attachments

  • cities_usa.png
    cities_usa.png
    122.7 KB · Views: 57

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Will col A ever have blank cells?
 
Upvote 0
In that case you could use
VBA Code:
   LastRow = Application.CountA(Range("A:A"))
 
Upvote 0
Thanks !

I have a similar case where the first row of the data is the 6th row, so the last row here would be row 27. Is there any solution for this ?
 
Upvote 0
Just add 5 to the result.
 
Upvote 0
yes, but what if the starting row is dynamic ? Sometimes it's the 6th, sometimes it's another...
 
Upvote 0
Then you will need to find the row of data, add that number to the result less 1
 
Upvote 0
Ok, any problems, just shout.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,827
Messages
6,121,803
Members
449,048
Latest member
greyangel23

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