Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Addressing cells in a NamedRange

To make a long story short, you can't please all the people all the time. I
have written a report that analyzes weekly data and puts the results onto a
report-like sheet. I have written my code directly to the display cells in
the usual manner. For the 4th time now, they have decided to re-arrange the
look and format of my report sheet. Naturally, they want me to re-write the
code again to place the results where they want them. I also know that this
will never end, like the wife moving around the furniture just to see how it
would look and fit.
And now for the question. I could take each section of the report and make
them Named Ranges and have the code write to the range names, wherever they
may be relocated on the sheet. How would I refer code to a specific cell
location within that range?
For example I now put data into "H9" by writing Range("H9").Value = dataA +
dataB. If "H9" is within Named Range "ProfitMargin" and is 4 cells down and
3 cells right of the upper left corner of the range, how would I code to
that range position.

Any help would be appreciated while I still have some hair and sense of
humor.
Mike


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Addressing cells in a NamedRange

Mike,

You'll need to have the rest of your sense of humor removed prior to
continuing <g

For example I now put data into "H9" by writing Range("H9").Value = dataA

+
dataB. If "H9" is within Named Range "ProfitMargin" and is 4 cells down

and
3 cells right of the upper left corner of the range, how would I code to
that range position.



Range("ProfitMargin").Cells(4,3)
Range("ProfitMargin")(4,3)
Range("ProfitMargin").Offset(3,2)
Range("ProfitMargin").Range("C4")

would all reference the cell in the 4th row and 3rd column of the range
"ProfitMargin"

Note: I wasn't sure if by 4 cells down you mean count down 4 cells to get to
the fifth row.... but you should get the picture.

HTH,
Bernie
MS Excel MVP

"Mike" wrote in message
...
To make a long story short, you can't please all the people all the time.

I
have written a report that analyzes weekly data and puts the results onto

a
report-like sheet. I have written my code directly to the display cells in
the usual manner. For the 4th time now, they have decided to re-arrange

the
look and format of my report sheet. Naturally, they want me to re-write

the
code again to place the results where they want them. I also know that

this
will never end, like the wife moving around the furniture just to see how

it
would look and fit.
And now for the question. I could take each section of the report and make
them Named Ranges and have the code write to the range names, wherever

they
may be relocated on the sheet. How would I refer code to a specific cell
location within that range?
For example I now put data into "H9" by writing Range("H9").Value = dataA

+
dataB. If "H9" is within Named Range "ProfitMargin" and is 4 cells down

and
3 cells right of the upper left corner of the range, how would I code to
that range position.

Any help would be appreciated while I still have some hair and sense of
humor.
Mike




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Addressing cells in a NamedRange

Hi Mike,

If "H9" is within Named Range "ProfitMargin" and is 4 cells down and 3

cells right of the upper left corner of the range, how would I code to that
range position.<

Try:

Range("ProfitMargin")(1).Offset(4, 3).Value = "yourvalue"

---
Regards,
Noran

"Mike" wrote in message
...
To make a long story short, you can't please all the people all the time.

I
have written a report that analyzes weekly data and puts the results onto

a
report-like sheet. I have written my code directly to the display cells in
the usual manner. For the 4th time now, they have decided to re-arrange

the
look and format of my report sheet. Naturally, they want me to re-write

the
code again to place the results where they want them. I also know that

this
will never end, like the wife moving around the furniture just to see how

it
would look and fit.
And now for the question. I could take each section of the report and make
them Named Ranges and have the code write to the range names, wherever

they
may be relocated on the sheet. How would I refer code to a specific cell
location within that range?
For example I now put data into "H9" by writing Range("H9").Value = dataA

+
dataB. If "H9" is within Named Range "ProfitMargin" and is 4 cells down

and
3 cells right of the upper left corner of the range, how would I code to
that range position.

Any help would be appreciated while I still have some hair and sense of
humor.
Mike




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Addressing cells in a NamedRange

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")




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Addressing cells in a NamedRange

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")








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Addressing cells in a NamedRange

Mike Fogleman wrote:

Does the (1) or Cells(1,1) set the reference point within the range to
Offset from?


No; it limits the returned range to only the first cell, rather than a
range of the same size as ProfitMargin.

Alan Beban
"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")






  #7   Report Post  
Posted to microsoft.public.excel.programming
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")








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
How to Add NamedRange Controls to Worksheets? lijipan Excel Worksheet Functions 0 November 16th 07 04:40 PM
absolute addressing and inserting new cells flyswiftly Excel Discussion (Misc queries) 3 September 19th 06 12:22 AM
Addressing cells on inactive sheets John Duffus Excel Discussion (Misc queries) 4 October 22nd 05 06:13 PM
Addressing cells without selecting Robert Christie[_3_] Excel Programming 6 March 4th 04 12:05 PM
sum (column 2 of namedrange) Alan Beban[_3_] Excel Programming 2 August 21st 03 10:11 PM


All times are GMT +1. The time now is 10:39 PM.

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"