Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
don don is offline
external usenet poster
 
Posts: 8
Default resizing a range

When resizing a range, excel doesn't seem to acknowledge the new size
In this example rect is increased by 1 row and 1 column.
yet when the number of rows is asked for in the msgbox in replies with
8.
It seems that it should recognize the new size.
How do you get it to acknowledge the new dimensions.
Thanks
Don


Sub resize()
Worksheets("Sheet3").Activate
Set rect = Range("a1:c8")
numRows = rect.Rows.Count
numColumns = rect.Columns.Count
rect.resize(numRows + 1, numColumns + 1).Select
MsgBox rect.Rows.Count
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default resizing a range

Try:


Sub resize()
Worksheets("Sheet3").Activate
Set rect = Range("a1:c8")
numRows = rect.Rows.Count
numColumns = rect.Columns.Count
rect.resize(numRows + 1, numColumns + 1).Select
Set rect = Selection
MsgBox rect.Rows.Count
End Sub

Looks like the re-size increased the Selected region, but you still need the
set to increase rect.
--
Gary's Student


"don" wrote:

When resizing a range, excel doesn't seem to acknowledge the new size
In this example rect is increased by 1 row and 1 column.
yet when the number of rows is asked for in the msgbox in replies with
8.
It seems that it should recognize the new size.
How do you get it to acknowledge the new dimensions.
Thanks
Don


Sub resize()
Worksheets("Sheet3").Activate
Set rect = Range("a1:c8")
numRows = rect.Rows.Count
numColumns = rect.Columns.Count
rect.resize(numRows + 1, numColumns + 1).Select
MsgBox rect.Rows.Count
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default resizing a range

It doesn't look to me as though you have resized the range "rect" -
you've merely made a selection of some cells based on a resizing of that
range.

Try inserting:

Set RECT = RECT.resize(numRows + 1, numcolumns + 1)

in place of the line before the MSGBOX.

--
Gordon Rainsford

London UK

don wrote:

When resizing a range, excel doesn't seem to acknowledge the new size
In this example rect is increased by 1 row and 1 column.
yet when the number of rows is asked for in the msgbox in replies with
8.
It seems that it should recognize the new size.
How do you get it to acknowledge the new dimensions.
Thanks
Don


Sub resize()
Worksheets("Sheet3").Activate
Set rect = Range("a1:c8")
numRows = rect.Rows.Count
numColumns = rect.Columns.Count
rect.resize(numRows + 1, numColumns + 1).Select
MsgBox rect.Rows.Count
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default resizing a range

Your statement

rect.resize(numRows + 1, numColumns + 1).Select

Selects a larger area, but doesn't change rect.

If you're trying to change rect, you can use something like

Set rect = rect.Resize(numRows + 1, numColumns + 1)
rect.Select

or, if you just want the size of the selected area, use the Selection
object directly:

Msgbox Selection.Rows.Count


In article ,
don wrote:

When resizing a range, excel doesn't seem to acknowledge the new size
In this example rect is increased by 1 row and 1 column.
yet when the number of rows is asked for in the msgbox in replies with
8.
It seems that it should recognize the new size.
How do you get it to acknowledge the new dimensions.
Thanks
Don


Sub resize()
Worksheets("Sheet3").Activate
Set rect = Range("a1:c8")
numRows = rect.Rows.Count
numColumns = rect.Columns.Count
rect.resize(numRows + 1, numColumns + 1).Select
MsgBox rect.Rows.Count
End Sub

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
resizing a range of cells ckane Excel Discussion (Misc queries) 4 May 3rd 07 06:08 PM
resizing a range don Excel Programming 3 February 18th 06 03:00 AM
Resizing my range - End row Jacqui Excel Programming 3 November 1st 05 06:00 PM
resizing a range Tim Kredlo Excel Programming 1 September 27th 05 08:30 PM
Resizing a Range NetWave128[_3_] Excel Programming 3 April 24th 04 11:16 AM


All times are GMT +1. The time now is 01:45 PM.

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

About Us

"It's about Microsoft Excel"