Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Addressing in VBA Richard Excel Discussion (Misc queries) 1 January 23rd 08 01:40 AM
VBA and range addressing C Brandt Excel Discussion (Misc queries) 3 July 31st 07 04:38 PM
Cell Addressing John Calder New Users to Excel 3 March 9th 07 12:32 PM
Relative Addressing Bill Martin -- (Remove NOSPAM from address) Excel Discussion (Misc queries) 4 February 20th 05 04:43 AM
Addressing a group of Named Ranges Mike Fogleman Excel Programming 5 May 18th 04 02:43 PM


All times are GMT +1. The time now is 04:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"