Select last row in range

moradisndat

New Member
Joined
Feb 19, 2021
Messages
15
Office Version
  1. 2007
Platform
  1. Windows
Using excel 2007. I started with range of 3 columns and about 26,000 rows. Then used data outline and group with subtotals ( rowlevels:=2 ) so that only the subtotals were visible.

Next, copied only the visible cells and pasted in new location. This new range of cells is G13:I28.
I am able to select the range with Range("G13").CurrentRegion.Select. But what I need to do is select H13:H28 and I13:I28.

I tried SpecialCells.xlCellTypeLastCell but it selects a blank cell around 26k rows since the imported data went that far.

I tried recording a macro to see what code to use when pressing ctrl+shift+down but it used specific cell reference H13:H28. It needs to be dynamic reference because the amount of records will vary each day. So how do I refer to the last cell in column H within that selected range? Please excuse me if the question is unclear. I'm just learning and dont know all the terms yet.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,162
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Range("H13:I" & Range("H" & Rows.Count).End(xlUp).Row).Select
 
Solution

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,162
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,140,929
Messages
5,703,225
Members
421,285
Latest member
Bebek

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
Top