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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
How about
VBA Code:
Range("H13:I" & Range("H" & Rows.Count).End(xlUp).Row).Select
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,665
Members
449,045
Latest member
Marcus05

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