Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 61
Default How to calculate (generate) a cell reference

I need a way to generate a cell address (row,column) from the value in
another cell and be able to use the contents of that in a calculation.

Here's my situation:

I have a table of mileage readings for my car taken at odd intervals.
Note that the "[Row]" column is the actual row number in the
spreadsheet and not part of the data. It is included because I want to
reference it later.

[Row] Date Odom Miles Days Mos Yrs M/Dy M/Mo Mi/Yr
13 3/13/05 48,041 1,141 50 1.64 0.14 23 695 8,335
14 7/10/05 50,922 2,881 119 3.91 0.33 24 737 8,843
15 10/29/05 52,176 1,254 111 3.65 0.30 11 344 4,126
16 12/15/05 55,338 3,162 47 1.54 0.13 67 2,048 24,573
17 5/01/06 57,767 2,429 137 4.50 0.38 18 540 6,476
18 6/30/06 58,494 727 60 1.97 0.16 12 369 4,426
19 10/12/06 62,144 3,650 104 3.42 0.28 35 1,068 12,819
20 2/02/07 65,368 3,224 113 3.71 0.31 29 868 10,421
21 3/12/07 65,719 351 38 1.25 0.10 9 281 3,374

The last column calculates the annualized miles/year based on the last
two readings. The reading are at irregular intervals, which makes it
difficult to calculate average mileage.

My idea was to add a row or two at the bottom of the table where I
would calculate the averages across enough intervals to span a year or
two. I could do the last 3 or 4 or 5 intervals and that would probably
be good enough, but what I'd like to do (maybe more for the learning
experience than the actual usefulness) is to add a new column (Row) in
which I could put the row number of the interval I want to compare
with. I could then choose an interval that is close to 1 or 2 or 3
years back and get the desired averages.

Here is an example using the data from the table above and choosing
rows that are about 1 and 2 years back. The new "Row" column is where
I would put the row number that I want to compare the last row in the
table against:

[Row] Row Date Odom Miles Days Mos Yrs M/Dy M/Mo Mi/Yr
23 16 12/15/05 55,338 10,381 452 14.85 1.24 23 699 8,389
24 13 3/13/05 48,041 17,678 729 23.95 2.00 24 738 8,857

This table was generated using actual cell references. The date cell
is "=B16", the Odom cell is "=C16", the Miles cell is "=C21-C16", and
the Miles cell is "=B21-B16".

What I need is a way to replace the "16" in each of these formulas
with the contents of cell A23. I can't seem to quite get it to work.

I think the solution is some combination of the cell() function and
the address() function, but I can't get it to work.

Using the address() function, I was able to obtain the address of the
cell:

=ADDRESS(A26,2) == "$B$16"
=ADDRESS(A26,2,4) == "B16"

Using the cell() function, I was able to obtain the contents of the
cell:

=CELL("contents",B16) == 12/15/05
=CELL("contents",C16) == 55,338

But when I try to combine these functions, I get an error:

=CELL("contents",ADDRESS(A26,2,4)) == Error

What am I doing wrong?

--
Running Excel 2000 SP-3 on Windows 2000
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 61
Default How to calculate (generate) a cell reference

On Mon, 12 Mar 2007 23:10:45 -0700, LurfysMa
wrote:

I need a way to generate a cell address (row,column) from the value in
another cell and be able to use the contents of that in a calculation.

Here's my situation:

I have a table of mileage readings for my car taken at odd intervals.
Note that the "[Row]" column is the actual row number in the
spreadsheet and not part of the data. It is included because I want to
reference it later.

[Row] Date Odom Miles Days Mos Yrs M/Dy M/Mo Mi/Yr
13 3/13/05 48,041 1,141 50 1.64 0.14 23 695 8,335
14 7/10/05 50,922 2,881 119 3.91 0.33 24 737 8,843
15 10/29/05 52,176 1,254 111 3.65 0.30 11 344 4,126
16 12/15/05 55,338 3,162 47 1.54 0.13 67 2,048 24,573
17 5/01/06 57,767 2,429 137 4.50 0.38 18 540 6,476
18 6/30/06 58,494 727 60 1.97 0.16 12 369 4,426
19 10/12/06 62,144 3,650 104 3.42 0.28 35 1,068 12,819
20 2/02/07 65,368 3,224 113 3.71 0.31 29 868 10,421
21 3/12/07 65,719 351 38 1.25 0.10 9 281 3,374

The last column calculates the annualized miles/year based on the last
two readings. The reading are at irregular intervals, which makes it
difficult to calculate average mileage.

My idea was to add a row or two at the bottom of the table where I
would calculate the averages across enough intervals to span a year or
two. I could do the last 3 or 4 or 5 intervals and that would probably
be good enough, but what I'd like to do (maybe more for the learning
experience than the actual usefulness) is to add a new column (Row) in
which I could put the row number of the interval I want to compare
with. I could then choose an interval that is close to 1 or 2 or 3
years back and get the desired averages.

Here is an example using the data from the table above and choosing
rows that are about 1 and 2 years back. The new "Row" column is where
I would put the row number that I want to compare the last row in the
table against:

[Row] Row Date Odom Miles Days Mos Yrs M/Dy M/Mo Mi/Yr
23 16 12/15/05 55,338 10,381 452 14.85 1.24 23 699 8,389
24 13 3/13/05 48,041 17,678 729 23.95 2.00 24 738 8,857

This table was generated using actual cell references. The date cell
is "=B16", the Odom cell is "=C16", the Miles cell is "=C21-C16", and
the Miles cell is "=B21-B16".

What I need is a way to replace the "16" in each of these formulas
with the contents of cell A23. I can't seem to quite get it to work.

I think the solution is some combination of the cell() function and
the address() function, but I can't get it to work.

Using the address() function, I was able to obtain the address of the
cell:

=ADDRESS(A26,2) == "$B$16"
=ADDRESS(A26,2,4) == "B16"

Using the cell() function, I was able to obtain the contents of the
cell:

=CELL("contents",B16) == 12/15/05
=CELL("contents",C16) == 55,338

But when I try to combine these functions, I get an error:

=CELL("contents",ADDRESS(A26,2,4)) == Error

What am I doing wrong?


I think I found one way to handle this using the indirect() function:

=INDIRECT(ADDRESS(A26,2,4))

Is there a better way?

Why doesn't the cell() function work?

Thanks

--
Running Excel 2000 SP-3 on Windows 2000
  #3   Report Post  
Posted to microsoft.public.excel.newusers
Max Max is offline
external usenet poster
 
Posts: 9,221
Default How to calculate (generate) a cell reference

If I've guessed your intents correctly, here's a much easier approach using
INDEX/MATCH to extract the data for any 2 dates from your source table for
the comparison calcs ..

A nicely rendered sample is available at:
http://cjoint.com/?dnjCgQuJbK
Extract data from table for comparison.xls
(.. savefile.com is still down for uploading ..)

Assuming the source table is within A1:I10

We'll use an empty area below the table to set it up

Create a DV list to select the 2 dates for the comparison
Select A14:A15
Click Data Validation
Allow: List
Source: =$A$2:$A$10
Click OK. Format A14:A15 as dates

Then place in B14:
=IF($A14="","",INDEX(B$2:B$10,MATCH($A14,$A$2:$A$1 0,0)))
Copy B14 across to I14, fill down to I15, to extract the data corresponding
to the 2 dates in A14:A15

Frame up your calcs as required in row 16, eg
in C16: =IF(OR(B14="",B15=""),"",B15-B14)
in D16: =IF(OR(A14="",A15=""),"",A15-A14)
etc

There, you're all ready to go. Just select any 2 dates in A14 & A15 (an
earlier date in A14, a later date in A15) and you would have the extracts and
comparisons all nicely done !
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"LurfysMa" wrote:
On Mon, 12 Mar 2007 23:10:45 -0700, LurfysMa
wrote:

I need a way to generate a cell address (row,column) from the value in
another cell and be able to use the contents of that in a calculation.

Here's my situation:

I have a table of mileage readings for my car taken at odd intervals.
Note that the "[Row]" column is the actual row number in the
spreadsheet and not part of the data. It is included because I want to
reference it later.

[Row] Date Odom Miles Days Mos Yrs M/Dy M/Mo Mi/Yr
13 3/13/05 48,041 1,141 50 1.64 0.14 23 695 8,335
14 7/10/05 50,922 2,881 119 3.91 0.33 24 737 8,843
15 10/29/05 52,176 1,254 111 3.65 0.30 11 344 4,126
16 12/15/05 55,338 3,162 47 1.54 0.13 67 2,048 24,573
17 5/01/06 57,767 2,429 137 4.50 0.38 18 540 6,476
18 6/30/06 58,494 727 60 1.97 0.16 12 369 4,426
19 10/12/06 62,144 3,650 104 3.42 0.28 35 1,068 12,819
20 2/02/07 65,368 3,224 113 3.71 0.31 29 868 10,421
21 3/12/07 65,719 351 38 1.25 0.10 9 281 3,374

The last column calculates the annualized miles/year based on the last
two readings. The reading are at irregular intervals, which makes it
difficult to calculate average mileage.

My idea was to add a row or two at the bottom of the table where I
would calculate the averages across enough intervals to span a year or
two. I could do the last 3 or 4 or 5 intervals and that would probably
be good enough, but what I'd like to do (maybe more for the learning
experience than the actual usefulness) is to add a new column (Row) in
which I could put the row number of the interval I want to compare
with. I could then choose an interval that is close to 1 or 2 or 3
years back and get the desired averages.

Here is an example using the data from the table above and choosing
rows that are about 1 and 2 years back. The new "Row" column is where
I would put the row number that I want to compare the last row in the
table against:

[Row] Row Date Odom Miles Days Mos Yrs M/Dy M/Mo Mi/Yr
23 16 12/15/05 55,338 10,381 452 14.85 1.24 23 699 8,389
24 13 3/13/05 48,041 17,678 729 23.95 2.00 24 738 8,857

This table was generated using actual cell references. The date cell
is "=B16", the Odom cell is "=C16", the Miles cell is "=C21-C16", and
the Miles cell is "=B21-B16".

What I need is a way to replace the "16" in each of these formulas
with the contents of cell A23. I can't seem to quite get it to work.

I think the solution is some combination of the cell() function and
the address() function, but I can't get it to work.

Using the address() function, I was able to obtain the address of the
cell:

=ADDRESS(A26,2) == "$B$16"
=ADDRESS(A26,2,4) == "B16"

Using the cell() function, I was able to obtain the contents of the
cell:

=CELL("contents",B16) == 12/15/05
=CELL("contents",C16) == 55,338

But when I try to combine these functions, I get an error:

=CELL("contents",ADDRESS(A26,2,4)) == Error

What am I doing wrong?


I think I found one way to handle this using the indirect() function:

=INDIRECT(ADDRESS(A26,2,4))

Is there a better way?

Why doesn't the cell() function work?

Thanks

--
Running Excel 2000 SP-3 on Windows 2000

  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 61
Default How to calculate (generate) a cell reference

On Tue, 13 Mar 2007 01:39:03 -0700, Max wrote:

If I've guessed your intents correctly, here's a much easier approach using
INDEX/MATCH to extract the data for any 2 dates from your source table for
the comparison calcs ..

A nicely rendered sample is available at:
http://cjoint.com/?dnjCgQuJbK
Extract data from table for comparison.xls
(.. savefile.com is still down for uploading ..)

Assuming the source table is within A1:I10

We'll use an empty area below the table to set it up

Create a DV list to select the 2 dates for the comparison
Select A14:A15
Click Data Validation
Allow: List
Source: =$A$2:$A$10
Click OK. Format A14:A15 as dates

Then place in B14:
=IF($A14="","",INDEX(B$2:B$10,MATCH($A14,$A$2:$A$ 10,0)))
Copy B14 across to I14, fill down to I15, to extract the data corresponding
to the 2 dates in A14:A15

Frame up your calcs as required in row 16, eg
in C16: =IF(OR(B14="",B15=""),"",B15-B14)
in D16: =IF(OR(A14="",A15=""),"",A15-A14)
etc

There, you're all ready to go. Just select any 2 dates in A14 & A15 (an
earlier date in A14, a later date in A15) and you would have the extracts and
comparisons all nicely done !


Thanks, Max. I think you have very correctly guessed my intentions.
I'm not sure, because your solution is beyond my skills at the moment.
I will play with it and see if I can figure it out.

Thanks for the suggestion. It's always great to learn a new approach.

--
Running Excel 2000 SP-3 on Windows 2000
  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 61
Default How to calculate (generate) a cell reference

On Tue, 13 Mar 2007 01:39:03 -0700, Max wrote:

If I've guessed your intents correctly, here's a much easier approach using
INDEX/MATCH to extract the data for any 2 dates from your source table for
the comparison calcs ..

A nicely rendered sample is available at:
http://cjoint.com/?dnjCgQuJbK
Extract data from table for comparison.xls
(.. savefile.com is still down for uploading ..)

Assuming the source table is within A1:I10

We'll use an empty area below the table to set it up

Create a DV list to select the 2 dates for the comparison
Select A14:A15
Click Data Validation
Allow: List
Source: =$A$2:$A$10
Click OK. Format A14:A15 as dates

Then place in B14:
=IF($A14="","",INDEX(B$2:B$10,MATCH($A14,$A$2:$A$ 10,0)))
Copy B14 across to I14, fill down to I15, to extract the data corresponding
to the 2 dates in A14:A15

Frame up your calcs as required in row 16, eg
in C16: =IF(OR(B14="",B15=""),"",B15-B14)
in D16: =IF(OR(A14="",A15=""),"",A15-A14)
etc

There, you're all ready to go. Just select any 2 dates in A14 & A15 (an
earlier date in A14, a later date in A15) and you would have the extracts and
comparisons all nicely done !


Thank you so much for that tip. I was able to find lots of examples
online and have a version of what you suggest working.

You are correct that this is far superior to my approach.

Not only does it avoid most of the problems I was encountering, but it
will find the closest match. It does not require an exact match. Since
my data is indexed by date (and also by mileage, if I decide that is
useful), I can get it to select a date that it at least n months (or
years) back. Thaty way, I don't have to choose the entries at all and
it updates itself when I add a row (if I am careful about how it do
it).

I am in your debt.

--
Running Excel 2000 SP-3 on Windows 2000


  #6   Report Post  
Posted to microsoft.public.excel.newusers
Max Max is offline
external usenet poster
 
Posts: 9,221
Default How to calculate (generate) a cell reference

Glad it helped, LurfysMa.
You're welcome.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"LurfysMa" wrote in message
...
Thank you so much for that tip. I was able to find lots of examples
online and have a version of what you suggest working.

You are correct that this is far superior to my approach.

Not only does it avoid most of the problems I was encountering, but it
will find the closest match. It does not require an exact match. Since
my data is indexed by date (and also by mileage, if I decide that is
useful), I can get it to select a date that it at least n months (or
years) back. Thaty way, I don't have to choose the entries at all and
it updates itself when I add a row (if I am careful about how it do
it).

I am in your debt.



  #7   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 61
Default How to calculate (generate) a cell reference

On Mon, 12 Mar 2007 23:34:52 -0700, LurfysMa
wrote:

On Mon, 12 Mar 2007 23:10:45 -0700, LurfysMa
wrote:

I need a way to generate a cell address (row,column) from the value in
another cell and be able to use the contents of that in a calculation.

Here's my situation:

I have a table of mileage readings for my car taken at odd intervals.
Note that the "[Row]" column is the actual row number in the
spreadsheet and not part of the data. It is included because I want to
reference it later.

[Row] Date Odom Miles Days Mos Yrs M/Dy M/Mo Mi/Yr
13 3/13/05 48,041 1,141 50 1.64 0.14 23 695 8,335
14 7/10/05 50,922 2,881 119 3.91 0.33 24 737 8,843
15 10/29/05 52,176 1,254 111 3.65 0.30 11 344 4,126
16 12/15/05 55,338 3,162 47 1.54 0.13 67 2,048 24,573
17 5/01/06 57,767 2,429 137 4.50 0.38 18 540 6,476
18 6/30/06 58,494 727 60 1.97 0.16 12 369 4,426
19 10/12/06 62,144 3,650 104 3.42 0.28 35 1,068 12,819
20 2/02/07 65,368 3,224 113 3.71 0.31 29 868 10,421
21 3/12/07 65,719 351 38 1.25 0.10 9 281 3,374

The last column calculates the annualized miles/year based on the last
two readings. The reading are at irregular intervals, which makes it
difficult to calculate average mileage.

My idea was to add a row or two at the bottom of the table where I
would calculate the averages across enough intervals to span a year or
two. I could do the last 3 or 4 or 5 intervals and that would probably
be good enough, but what I'd like to do (maybe more for the learning
experience than the actual usefulness) is to add a new column (Row) in
which I could put the row number of the interval I want to compare
with. I could then choose an interval that is close to 1 or 2 or 3
years back and get the desired averages.

Here is an example using the data from the table above and choosing
rows that are about 1 and 2 years back. The new "Row" column is where
I would put the row number that I want to compare the last row in the
table against:

[Row] Row Date Odom Miles Days Mos Yrs M/Dy M/Mo Mi/Yr
23 16 12/15/05 55,338 10,381 452 14.85 1.24 23 699 8,389
24 13 3/13/05 48,041 17,678 729 23.95 2.00 24 738 8,857

This table was generated using actual cell references. The date cell
is "=B16", the Odom cell is "=C16", the Miles cell is "=C21-C16", and
the Miles cell is "=B21-B16".

What I need is a way to replace the "16" in each of these formulas
with the contents of cell A23. I can't seem to quite get it to work.

I think the solution is some combination of the cell() function and
the address() function, but I can't get it to work.

Using the address() function, I was able to obtain the address of the
cell:

=ADDRESS(A26,2) == "$B$16"
=ADDRESS(A26,2,4) == "B16"

Using the cell() function, I was able to obtain the contents of the
cell:

=CELL("contents",B16) == 12/15/05
=CELL("contents",C16) == 55,338

But when I try to combine these functions, I get an error:

=CELL("contents",ADDRESS(A26,2,4)) == Error

What am I doing wrong?


I think I found one way to handle this using the indirect() function:

=INDIRECT(ADDRESS(A26,2,4))


Apparently, I don't even need the address() function:

=INDIRECT("B"&A26)

also works. :-)


--
Running Excel 2000 SP-3 on Windows 2000
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
Auto calculate absolute cell reference Teri Excel Discussion (Misc queries) 3 March 5th 07 09:00 PM
Formula 'mis' calculate when reference cell contains a "0" Rachel Excel Discussion (Misc queries) 1 December 12th 06 07:43 PM
generate a random number and use if function to generate new data Dogdoc1142 Excel Worksheet Functions 4 April 26th 06 03:44 AM
Generate random numberes using reference to the other cell. ramana Excel Worksheet Functions 7 October 31st 05 07:09 AM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM


All times are GMT +1. The time now is 07:11 AM.

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

About Us

"It's about Microsoft Excel"