Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would like to add a cell to an existing range in a macro. I am new to
programming ranges and need some direction on this. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you mean just make the range bigger?
If yes, you can use .resize() to resize the original range: range("a1").resize(1,10) refers to a range that is 1 row by 10 columns starting in A1. Range("a1:B99").resize(1,10) is the same as that other! 1 row by 10 columns starting in A1. So if you wanted to resize an existing range, you could do: dim myRng as Range dim myNewRng as range Set myrng = worksheets("sheet9999").range("c9:e44") with myrng set mynewrng = .resize(.rows.count+1,.columns.count+1) end with It added 1 to both the number of rows and the number of columns. And you don't have to use a new variable if you don't want to: with myrng set myrng = .resize(.rows.count+1,.columns.count+1) end with ======= As an aside, there's a way to "move" to a different location based on that original range. Take a look at .offset() in VBA's help when you have time. Edd wrote: I would like to add a cell to an existing range in a macro. I am new to programming ranges and need some direction on this. -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On May 27, 10:00 am, Edd wrote:
I would like to add a cell to an existing range in a macro. I am new to programming ranges and need some direction on this. Set MyRange = Union(MyRange, Range("C1")) adds C1 to a previously Set range (MyRange) Ken Johnson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selecting range in list of range names depending on a cell informa | Excel Discussion (Misc queries) | |||
Change cell colour for a cell or range within a predefined range | Excel Programming | |||
Comparing values in non contigious cells | Excel Programming | |||
Multiply non-contigious arrays | Excel Discussion (Misc queries) | |||
Range.Find returns cell outside of range when range set to single cell | Excel Programming |