Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Addressing ranges
Dim c as Range
Assuming c is a single cell range, and I want to write a value into the adjacent column, is there any advantage/disadvantage to using c.offset(0,1) vs c(1,2) ?? c(1,2) is more compact. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Addressing ranges
On Jun 15, 7:48*am, Ron Rosenfeld wrote:
Dim c as Range Assuming c is a single cell range, and I want to write a value into the adjacent column, is there any advantage/disadvantage to using c.offset(0,1) * vs c(1,2) ?? c(1,2) is more compact. Havent seen this abbreviated style before so if it works, the problems I would foresee would be 1) more difficult for others to decipher your code 2) possibly incompatible with alternative software/future versions. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Addressing ranges
On Tue, 15 Jun 2010 05:25:48 -0700 (PDT), Jef Gorbach
wrote: Havent seen this abbreviated style before so if it works, the problems I would foresee would be 1) more difficult for others to decipher your code Well, if they're not familiar with the notation, then I would agree. But I would think most are. There are arguments about whether one should specify default properties (actually, which of the default properties), or not, but I'm curious about performance issues. If c is set to some Range object representing a single cell, then: c(1,2) is equivalent to: excel.application.ActiveSheet.c.item(1,2) and should return the same result as: excel.application.ActiveSheet.c.offset(0,1) 2) possibly incompatible with alternative software/future versions. Why do you think it might be incompatible with future versions? Maybe, since you are not familiar with the notation, I should rephrase the question: Is there an advantage/disadvantage to using the Item property vs using the Offset property in specifying a single cell that is relative to the base cell. Of course, if the Range expression is a multicell range, the Item property (using this notation) will only return a single cell (which is what I want), whereas the Offset property will return a range of the same size and shape. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Addressing ranges
I like the .offset() style better, but I think it's a personal (or
department/company) choice. I have no idea if one is quicker than the other. And I don't care -- for the same reasons that Jef wrote. (But you should be able to read and understand both <vbg.) Chip Pearson has some notes written by Alan Beban: http://www.cpearson.com/excel/cells.htm It may be an interesting read for you. On 06/15/2010 06:48, Ron Rosenfeld wrote: Dim c as Range Assuming c is a single cell range, and I want to write a value into the adjacent column, is there any advantage/disadvantage to using c.offset(0,1) vs c(1,2) ?? c(1,2) is more compact. -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Addressing ranges
(I don't think Jef's compatibility reason is as good as his first. I'm not
worried about that.) On 06/15/2010 09:34, Dave Peterson wrote: I like the .offset() style better, but I think it's a personal (or department/company) choice. I have no idea if one is quicker than the other. And I don't care -- for the same reasons that Jef wrote. (But you should be able to read and understand both <vbg.) Chip Pearson has some notes written by Alan Beban: http://www.cpearson.com/excel/cells.htm It may be an interesting read for you. On 06/15/2010 06:48, Ron Rosenfeld wrote: Dim c as Range Assuming c is a single cell range, and I want to write a value into the adjacent column, is there any advantage/disadvantage to using c.offset(0,1) vs c(1,2) ?? c(1,2) is more compact. -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Addressing ranges
On Tue, 15 Jun 2010 09:34:23 -0500, Dave Peterson
wrote: I like the .offset() style better, but I think it's a personal (or department/company) choice. I used to use the Offset property frequently, but I've been starting to use the Item property. I guess it is a personal preference, although the Offset property would be my choice, I think, if I needed to refer to an entire range, rather than just a single cell. I have no idea if one is quicker than the other. And I don't care -- for the same reasons that Jef wrote. (But you should be able to read and understand both <vbg.) Chip Pearson has some notes written by Alan Beban: http://www.cpearson.com/excel/cells.htm It may be an interesting read for you. It was. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Addressing in VBA | Excel Discussion (Misc queries) | |||
VBA and range addressing | Excel Discussion (Misc queries) | |||
Cell Addressing | New Users to Excel | |||
Relative Addressing | Excel Discussion (Misc queries) | |||
Addressing a group of Named Ranges | Excel Programming |