Stripping row/col headings from a range (excel2000)

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Stripping row/col headings from a range (excel2000)

Post by ChrisGreaves »

I'm not the world's most powerful user of RANGE in Excel.
I am given a range which identifies a block of data, including a row of column headings and a column of row headings (please see image).
I want to obtain a range that describes just the numeric data.
I came up with this, but as always, wonder if there is a better way:

Code: Select all

Sub test()
    Dim rngData As Range
    Set rngData = selection
    Dim rngNumeric As Range
    Set rngNumeric = Range(rngData.Cells(2, 2), rngData(rngData.Rows.Count, rngData.Columns.Count))
    rngNumeric.Select
End Sub
My objective is to identify the data identified by the red rectangle below:
1.JPG
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.

User avatar
HansV
Administrator
Posts: 78568
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Stripping row/col headings from a range (excel2000)

Post by HansV »

Other options:

Set rngNumeric = rngData.Offset(1, 1).Resize(rngData.Rows.Count - 1, rngData.Columns.Count - 1)

or

Set rngNumeric = Range(rngData.Offset(1, 1), rngData.Offset(1, 1).End(xlDown).End(xlToRight))
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Stripping row/col headings from a range (excel2000)

Post by ChrisGreaves »

HansV wrote:Other options:
Thanks Hans.
(Mutters to self: "Oh Great; just when I thought I was getting the hang of Range I'm confronted with Resize ...") :laugh:
He who plants a seed, plants life.

User avatar
HansV
Administrator
Posts: 78568
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Stripping row/col headings from a range (excel2000)

Post by HansV »

Wait until I introduce you to Intersect and Union... :evilgrin:
Best wishes,
Hans