ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell as range (https://www.excelbanter.com/excel-programming/301214-cell-range.html)

Grace[_4_]

Cell as range
 
I am having trouble with all the help I'm getting about expanding a range
and I think it has to do with the fact that, when I have selected a single
cell, I am assuming that such is a range that can be expanded. Probably, it
is not. So, kindly tell me how to expand from a cell location that I have
selected to a "range", say by adding five more columns to the right. At
that point, I assume, I will have a range and, from there, I think I can
figure the rest out myself.

Thanks,
Grace



Frank Kabel

Cell as range
 
Hi Grace
also a single cell is an Range. try something like the following
sub foo()
dim rng as range
set rng = activesheet.range("B1")
rng.resize(1,6)
rng.value="myrange"
end sub

--
Regards
Frank Kabel
Frankfurt, Germany


Grace wrote:
I am having trouble with all the help I'm getting about expanding a
range and I think it has to do with the fact that, when I have
selected a single cell, I am assuming that such is a range that can
be expanded. Probably, it is not. So, kindly tell me how to expand
from a cell location that I have selected to a "range", say by adding
five more columns to the right. At that point, I assume, I will have
a range and, from there, I think I can figure the rest out myself.

Thanks,
Grace



Tom Ogilvy

Cell as range
 
ActiveCell.Resize(1,5) will be 5 cells in 1 row

ActiveCell.Resize(1,6) will be 6 cells in 1 rows (the original cell and 5
additional cells to the right.


If you will have data below that cell that you want to select

Range(ActiveCell,ActiveCell.End(xldown)).Resize(,6 ).Printout

change the 6 to a 5 if you want a total of 5 columns.

--
Regards,
Tom Ogilvy

"Grace" wrote in message
...
I am having trouble with all the help I'm getting about expanding a range
and I think it has to do with the fact that, when I have selected a single
cell, I am assuming that such is a range that can be expanded. Probably,

it
is not. So, kindly tell me how to expand from a cell location that I have
selected to a "range", say by adding five more columns to the right. At
that point, I assume, I will have a range and, from there, I think I can
figure the rest out myself.

Thanks,
Grace





Grace[_4_]

Cell as range
 
Thanks Tom and Frank!
Grace

"Tom Ogilvy" wrote in message
...
ActiveCell.Resize(1,5) will be 5 cells in 1 row

ActiveCell.Resize(1,6) will be 6 cells in 1 rows (the original cell and 5
additional cells to the right.


If you will have data below that cell that you want to select

Range(ActiveCell,ActiveCell.End(xldown)).Resize(,6 ).Printout

change the 6 to a 5 if you want a total of 5 columns.

--
Regards,
Tom Ogilvy

"Grace" wrote in message
...
I am having trouble with all the help I'm getting about expanding a

range
and I think it has to do with the fact that, when I have selected a

single
cell, I am assuming that such is a range that can be expanded.

Probably,
it
is not. So, kindly tell me how to expand from a cell location that I

have
selected to a "range", say by adding five more columns to the right. At
that point, I assume, I will have a range and, from there, I think I can
figure the rest out myself.

Thanks,
Grace








All times are GMT +1. The time now is 05:22 PM.

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