resize range

N

Norma

I'm having problems to resize a range.
my data looks like this

x a d
x a d
x a d
y b

when I select the data the last row is included. is there any way to resize
the selection and exclude the last row (y)

thank you
 
C

Chip Pearson

Try something like the following:

Dim Curr As Range
Dim R As Range
Set Curr = ActiveCell.CurrentRegion
With Curr
If .Rows.Count > 1 Then
Set R = .Resize(.Rows.Count - 1, .Columns.Count)
End If
End With
R.Select


The CurrentRegion Curr is the rectangular region containing the
ActiveCell that is bounded on the sides by either all blank cells or
the end of the worksheet. The range R will refer to the CurrentRegion
excluding the last row.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
N

Norma

Thank you so much, it works!!!!!!

Chip Pearson said:
Try something like the following:

Dim Curr As Range
Dim R As Range
Set Curr = ActiveCell.CurrentRegion
With Curr
If .Rows.Count > 1 Then
Set R = .Resize(.Rows.Count - 1, .Columns.Count)
End If
End With
R.Select


The CurrentRegion Curr is the rectangular region containing the
ActiveCell that is bounded on the sides by either all blank cells or
the end of the worksheet. The range R will refer to the CurrentRegion
excluding the last row.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top