Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Resize CurrentRegion by 2 rows at the bottom


Simply want to select the CurrentRegion, excluding the first two title rows,
including whatever number of columns there are.

Have tried a few dozen syntaxes, here's the latest that doesn't work...

Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(2, 0).Select
Selection.Resize(Rows - 2,).Select


If anyone can help it would be greatly appreciated.
- Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Resize CurrentRegion by 2 rows at the bottom

This will extend CurrentRange down by two rows:

Sub dural()
s = Split(ActiveCell.CurrentRegion.Address, "$")
s(UBound(s)) = s(UBound(s)) + 2
Range(Join(s, "$")).Select
End Sub

--
Gary''s Student - gsnu200836


"MikeF" wrote:


Simply want to select the CurrentRegion, excluding the first two title rows,
including whatever number of columns there are.

Have tried a few dozen syntaxes, here's the latest that doesn't work...

Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(2, 0).Select
Selection.Resize(Rows - 2,).Select


If anyone can help it would be greatly appreciated.
- Mike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Resize CurrentRegion by 2 rows at the bottom

Does this line of code do what you want?

Selection.CurrentRegion.Offset(2).Select

--
Rick (MVP - Excel)


"MikeF" wrote in message
...

Simply want to select the CurrentRegion, excluding the first two title
rows,
including whatever number of columns there are.

Have tried a few dozen syntaxes, here's the latest that doesn't work...

Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(2, 0).Select
Selection.Resize(Rows - 2,).Select


If anyone can help it would be greatly appreciated.
- Mike


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Resize CurrentRegion by 2 rows at the bottom

Sorry, I used the active selection instead of A1 that your code indicated
you wanted to use. Simply replace Selection with your "starter" cell...

Range("A1").CurrentRegion.Offset(2).Select

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Does this line of code do what you want?

Selection.CurrentRegion.Offset(2).Select

--
Rick (MVP - Excel)


"MikeF" wrote in message
...

Simply want to select the CurrentRegion, excluding the first two title
rows,
including whatever number of columns there are.

Have tried a few dozen syntaxes, here's the latest that doesn't work...

Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(2, 0).Select
Selection.Resize(Rows - 2,).Select


If anyone can help it would be greatly appreciated.
- Mike



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Resize CurrentRegion by 2 rows at the bottom

On Wed, 4 Mar 2009 05:55:00 -0800, MikeF
wrote:


Simply want to select the CurrentRegion, excluding the first two title rows,
including whatever number of columns there are.

Have tried a few dozen syntaxes, here's the latest that doesn't work...

Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(2, 0).Select
Selection.Resize(Rows - 2,).Select


If anyone can help it would be greatly appreciated.
- Mike


Here's an example with some debug.print commands so you can see what's going
on.

If the initial region is $A$1:$C$7, after running this Sub you should see
$A$3:$C$7



==================
Option Explicit
Sub RemoveTitles()
Dim c As Range
Set c = Range("A1").CurrentRegion
Debug.Print c.Address
Set c = c.Resize(c.Rows.Count - 2).Offset(2)
Debug.Print c.Address
End Sub
=========================
--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Resize CurrentRegion by 2 rows at the bottom

I see from your posting that I misinterpreted what the OP was looking for.
As you may remember from other postings of mine, I have this "thing" for
one-liners; so, while not a practical solution to the OP's question (I would
do it the way you posted), I thought those reading this thread might find
this one-liner of interest anyway...

Range("A3:" & Split(Range("A1").CurrentRegion.Address, ":")(1)).Select

It selects the same range your code would (if you had specified Select
instead of Address on your last line of code). HOWEVER, the code requires
that at least one line of data exists (or else the 2nd header row would be
selected).

--
Rick (MVP - Excel)


"Ron Rosenfeld" wrote in message
...
On Wed, 4 Mar 2009 05:55:00 -0800, MikeF
wrote:


Simply want to select the CurrentRegion, excluding the first two title
rows,
including whatever number of columns there are.

Have tried a few dozen syntaxes, here's the latest that doesn't work...

Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(2, 0).Select
Selection.Resize(Rows - 2,).Select


If anyone can help it would be greatly appreciated.
- Mike


Here's an example with some debug.print commands so you can see what's
going
on.

If the initial region is $A$1:$C$7, after running this Sub you should see
$A$3:$C$7



==================
Option Explicit
Sub RemoveTitles()
Dim c As Range
Set c = Range("A1").CurrentRegion
Debug.Print c.Address
Set c = c.Resize(c.Rows.Count - 2).Offset(2)
Debug.Print c.Address
End Sub
=========================
--ron


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Resize CurrentRegion by 2 rows at the bottom

On Wed, 4 Mar 2009 12:54:52 -0500, "Rick Rothstein"
wrote:

I see from your posting that I misinterpreted what the OP was looking for.
As you may remember from other postings of mine, I have this "thing" for
one-liners; so, while not a practical solution to the OP's question (I would
do it the way you posted), I thought those reading this thread might find
this one-liner of interest anyway...

Range("A3:" & Split(Range("A1").CurrentRegion.Address, ":")(1)).Select

It selects the same range your code would (if you had specified Select
instead of Address on your last line of code). HOWEVER, the code requires
that at least one line of data exists (or else the 2nd header row would be
selected).


What I noted about your previous posting was that it only moved the current
region down two rows, but didn't resize it.

You can combine my two lines into one (obviously excluding the debug.print
lines), but I chose not too to make it easier for the OP to follow the logic.
--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with Selection.CurrentRegion.Rows.Count? KenY Excel Programming 2 April 21st 10 11:01 AM
Incorrect CurrentRegion.SpecialCells(xlVisible).Rows.Count on filt KenY Excel Programming 2 February 6th 09 04:45 PM
Can't get to bottom right corner of window to resize? I figured it Michael NoNOTooMuch Excel Discussion (Misc queries) 1 April 14th 08 11:06 PM
How to select the bottom right cel in a 'CurrentRegion.selecion' Luc Excel Programming 3 March 3rd 07 07:58 PM
Selecting multiple rows within a CurrentRegion Brian J. Matuschak Excel Programming 1 May 18th 06 05:12 AM


All times are GMT +1. The time now is 02:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"