VBA Current region minus header and last column

seattlerose

New Member
Joined
Mar 8, 2012
Messages
23
I have code to minus header row but I also need to select current region minus header row and last column. Can anyone help.

Here is my current code

Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select

Thanks!!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try it like this...
Code:
[table="width: 500"]
[tr]
	[td]Selection.CurrentRegion.Offset(1).Resize(Selection.CurrentRegion.Rows.Count - 2).Select[/td]
[/tr]
[/table]
 
Upvote 0
Thanks but that's not quite what I was going for. I need the Header Row unselected and the last Column​ unselected . The code you provided unselects the header row and the last row.
 
Upvote 0
Thanks but that's not quite what I was going for. I need the Header Row unselected and the last Column​ unselected . The code you provided unselects the header row and the last row.
Sorry, I misread your original question. Try either of these (they are both the same except for how they are presented)...
Code:
[table="width: 500"]
[tr]
	[td][COLOR="#008000"][B]'As a one-liner
'----------------------------------[/B][/COLOR]
Selection.CurrentRegion.Offset(1).Resize(Selection.CurrentRegion.Rows.count - 1, Selection.CurrentRegion.Columns.count - 1).Select


[COLOR="#008000"][B]'Maybe easier to read
'----------------------------------[/B][/COLOR]
With Selection.CurrentRegion
  .Offset(1).Resize(.Rows.count - 1, .Columns.count - 1).Select
End With[/td]
[/tr]
[/table]
 
Upvote 0
Sorry, I misread your original question. Try either of these (they are both the same except for how they are presented)...
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD][COLOR=#008000][B]'As a one-liner
'----------------------------------[/B][/COLOR]
Selection.CurrentRegion.Offset(1).Resize(Selection.CurrentRegion.Rows.count - 1, Selection.CurrentRegion.Columns.count - 1).Select


[COLOR=#008000][B]'Maybe easier to read
'----------------------------------[/B][/COLOR]
With Selection.CurrentRegion
  .Offset(1).Resize(.Rows.count - 1, .Columns.count - 1).Select
End With[/TD]
[/TR]
</tbody>[/TABLE]

AWESOME!!! works great thanks
 
Upvote 0

Forum statistics

Threads
1,216,330
Messages
6,130,073
Members
449,556
Latest member
Sergiusz

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