View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Addressing cells in a NamedRange

Mike,

Though these are equivalent, and return the same cell, they are subtly
different:

'Select the first cell of the offset range
Range("ProfitMargin").Offset(3, 2).Cells(1,1)

'Select the first cell of the range to offset from
Range("ProfitMargin").Cells(1,1).Offset(3, 2)

The main difference is that if ProfitMargin were defined to include entire
rows, say, using the Offset method first would fail, since you can't offset
an entire row (columns 1 to 256) by two columns (you can't have columns 3 to
258, since 257 and 258 don't exist). These types of issues are probably
infrequently seen, since the typical usage is more likely to be

Range("ProfitMargin").Cells(4,3)
or
Range("ProfitMargin")(4,3)

HTH,
Bernie
MS Excel MVP

"Mike Fogleman" wrote in message
news:F6spc.53743$536.9188666@attbi_s03...
Does the (1) or Cells(1,1) set the reference point within the range to
Offset from?
"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Oops, got a little sloppy. That third one should be

Range("ProfitMargin").Offset(3, 2)(1)
or
Range("ProfitMargin").Offset(3, 2).Cells(1,1)

HTH,
Bernie
MS Excel MVP

"Bernie Deitrick" <deitbe @ consumer dot org wrote in
Range("ProfitMargin").Cells(4,3)
Range("ProfitMargin")(4,3)
Range("ProfitMargin").Offset(3,2)
Range("ProfitMargin").Range("C4")