ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selection.Resize error (https://www.excelbanter.com/excel-programming/377118-selection-resize-error.html)

[email protected]

Selection.Resize error
 
I want to starting at a single cell selection, offset two columns and
expand the selection two two cells.
So far I am using:

ActiveCell.Offset(0, 2).Select

Selection.Resize(0, 2).Select

However, I get the runtime error: Application-defined or
object-defined error

Probably just another case of me using something in the wrong place but
I cant see what else to do.

Any help will be appreciated.

Robert


[email protected]

Selection.Resize error
 

wrote:
I want to starting at a single cell selection, offset two columns and
expand the selection two two cells.
So far I am using:

ActiveCell.Offset(0, 2).Select

Selection.Resize(0, 2).Select

However, I get the runtime error: Application-defined or
object-defined error

Probably just another case of me using something in the wrong place but
I cant see what else to do.

Any help will be appreciated.

Robert


I forgot to say that when I start the code, I have a cell selected and
the error occurs on the second line of code

R


Peter T

Selection.Resize error
 
Selection.Offset(0, 2).Resize(2, 1).Select

The 'size' of a range must always be 1 or more rows and columns within the
limits of the sheet size.

Regards,
Peter T

wrote in message
ups.com...
I want to starting at a single cell selection, offset two columns and
expand the selection two two cells.
So far I am using:

ActiveCell.Offset(0, 2).Select

Selection.Resize(0, 2).Select

However, I get the runtime error: Application-defined or
object-defined error

Probably just another case of me using something in the wrong place but
I cant see what else to do.

Any help will be appreciated.

Robert




PCLIVE

Selection.Resize error
 
I'm not sure exactly what you want to do. What are you trying to do with
'Resize '?

If you just want to expand your selection to two cells after you offset two
columns, which two cells should be the selection.
Assuming adjacent columns:

ActiveCell.Offset(0, 2).Select
Range(ActiveCell, ActiveCell.Offset(0, 1)).Select

If you mean you want the two cells to be merged, then maybe:

ActiveCell.Offset(0, 2).Select
Range(ActiveCell, ActiveCell.Offset(0, 1)).Select
Selection.Merge

Regards,
Paul


wrote in message
ups.com...

wrote:
I want to starting at a single cell selection, offset two columns and
expand the selection two two cells.
So far I am using:

ActiveCell.Offset(0, 2).Select

Selection.Resize(0, 2).Select

However, I get the runtime error: Application-defined or
object-defined error

Probably just another case of me using something in the wrong place but
I cant see what else to do.

Any help will be appreciated.

Robert


I forgot to say that when I start the code, I have a cell selected and
the error occurs on the second line of code

R




Chip Pearson

Selection.Resize error
 
The problem is the 0 in the resize property. This tells Excel you want to
resize the range to 0 rows high. You can't have a range with 0 rows.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)

wrote in message
ups.com...

wrote:
I want to starting at a single cell selection, offset two columns and
expand the selection two two cells.
So far I am using:

ActiveCell.Offset(0, 2).Select

Selection.Resize(0, 2).Select

However, I get the runtime error: Application-defined or
object-defined error

Probably just another case of me using something in the wrong place but
I cant see what else to do.

Any help will be appreciated.

Robert


I forgot to say that when I start the code, I have a cell selected and
the error occurs on the second line of code

R




[email protected]

Selection.Resize error
 
Hi
You have siad your new range has 0 rows. Try
ActiveCell.Offset(0, 2).Select
Selection.Resize(, 2).Select

or better still
ActiveCell.Offset(0, 2).Resize(, 2).Select

This uses the same number of rows as ActiveCell. you could also use
Resize(1,2).
regards
Paul

wrote:

wrote:
I want to starting at a single cell selection, offset two columns and
expand the selection two two cells.
So far I am using:

ActiveCell.Offset(0, 2).Select

Selection.Resize(0, 2).Select

However, I get the runtime error: Application-defined or
object-defined error

Probably just another case of me using something in the wrong place but
I cant see what else to do.

Any help will be appreciated.

Robert


I forgot to say that when I start the code, I have a cell selected and
the error occurs on the second line of code

R



[email protected]

Selection.Resize error
 
Ahh, the light bulb is on Chip! The education continues
Thanks to all who replied
Robert

Chip Pearson wrote:
The problem is the 0 in the resize property. This tells Excel you want to
resize the range to 0 rows high. You can't have a range with 0 rows.




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

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