ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   resizing a range (https://www.excelbanter.com/excel-programming/353670-resizing-range.html)

Norman Jones

resizing a range
 
Hi Don,

Change:

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


to

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

---
Regards,
Norman



"don" wrote in message
...
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




don

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

Norman Jones

resizing a range
 
Hi Don.

That was imtended as:

Set rect = rect.resize(numRows + 1, numColumns + 1)

--
---
Regards,
Norman



Norman Jones

resizing a range
 
Hi Don,

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


Should read:

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



---
Regards,
Norman




All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com