Selection.Resize error

R

robert.hatcher

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
 
R

robert.hatcher

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
 
P

Peter T

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
 
P

PCLIVE

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
 
C

Chip Pearson

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)
 
P

paul.robinson

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
 
R

robert.hatcher

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top