Sorting in one tabs messes up formulas in another tab

Hi,

I'm not sure if this problem was solved before so sorry if this is a
repeat question. Let's say I have one spreadsheet tab that originally
has the following:

Col A Col B
Row 1: 3 3
Row 2: 5 5

In another tab, I have the following formulas that reference the 1st
tab:

Col A
Row 1: =average(A1:B1) - which would yield the number 3
Row 2: = average (A2:B2) - which would yield the number 5

Now let's say I resort all the data in the first tab, by col A, in
descending order. The first tab now looks like:

Col A Col B
Row 1: 5 5
Row 2: 3 3

All is well enough until you look at the values in the cells in the
2nd tab. The formulas stay the same, but this time they yield 5 for
cell A1 and 3 for cell A2. This is not the same values that those
cells originally had.

I had assumed that if I had resorted the cells in one tab, that the
formula in the other tab would know what rows to look at when the data
got resorted. But, I guess this is not the case. I had tried to avert
this problem by using absolute addresses in the formula, but this did
not help.

Does anyone know a way to code the formulas in the 2nd tab, such that
they reference the correct rows in the 1st tab? While I have presented
a simple example, the real world example is hundreds of rows long.

Although I could protect the 1st tab to prevent sorting, I do have a
periodic need to resort. The 1st file contains a list of items and
occassionally, I need to resort in alpha order.

Any help would be greatly appreciated.

Thanks,
Scotty81
0
schlagce (3)
3/6/2008 12:28:59 PM
excel 39879 articles. 2 followers. Follow

3 Replies
327 Views

Similar Articles

[PageSpeed] 12

The formulas you're using are referencing the cells....independent of the
values they contain. Sorting is the equivalent of re-typing the values in a
different order, not moving the cells.

It sounds like you want the formulas to adjust their references based on the
location of cell values. Your current structure wouldn't support that, but
this might be an approach you could use:

Example:
A1:D6 contains...

Seq_Name____Amt1___Amt2
1___Delta_____4_____40
2___Charlie___3_____30
3___Bravo_____2_____20
4___Alpha_____1_____10
5___Echo______5_____50

F2: (a seq to reference....eg 4)

This formula "finds" the Seq from F2 in Col_A and
returns the associated average of Cols C and D:
G2:
=AVERAGE(INDEX($C$2:$C$6,MATCH(F2,$A$2:$A$6,0)):INDEX($D$2:$D$6,MATCH(F2,$A$2:$A$6,0)))

If you sort the data in descending order by Seq, that formula will still
find the Seq from F2 in that data and return the same average. In the 
example,
G2 returns 5.5 before, and after, the sort.

Is that something you can work with?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)





<schlagce@airproducts.com> wrote in message
news:1932e92f-e39f-46ed-b593-2c2d0c69f042@e6g2000prf.googlegroups.com...
> Hi,
>
> I'm not sure if this problem was solved before so sorry if this is a
> repeat question. Let's say I have one spreadsheet tab that originally
> has the following:
>
> Col A Col B
> Row 1: 3 3
> Row 2: 5 5
>
> In another tab, I have the following formulas that reference the 1st
> tab:
>
> Col A
> Row 1: =average(A1:B1) - which would yield the number 3
> Row 2: = average (A2:B2) - which would yield the number 5
>
> Now let's say I resort all the data in the first tab, by col A, in
> descending order. The first tab now looks like:
>
> Col A Col B
> Row 1: 5 5
> Row 2: 3 3
>
> All is well enough until you look at the values in the cells in the
> 2nd tab. The formulas stay the same, but this time they yield 5 for
> cell A1 and 3 for cell A2. This is not the same values that those
> cells originally had.
>
> I had assumed that if I had resorted the cells in one tab, that the
> formula in the other tab would know what rows to look at when the data
> got resorted. But, I guess this is not the case. I had tried to avert
> this problem by using absolute addresses in the formula, but this did
> not help.
>
> Does anyone know a way to code the formulas in the 2nd tab, such that
> they reference the correct rows in the 1st tab? While I have presented
> a simple example, the real world example is hundreds of rows long.
>
> Although I could protect the 1st tab to prevent sorting, I do have a
> periodic need to resort. The 1st file contains a list of items and
> occassionally, I need to resort in alpha order.
>
> Any help would be greatly appreciated.
>
> Thanks,
> Scotty81



0
3/6/2008 12:55:42 PM
On Mar 6, 7:55=A0am, "Ron Coderre" <ronREMOVETHIScode...@bigfoot.com>
wrote:
> The formulas you're using are referencing the cells....independent of the
> values they contain. Sorting is the equivalent of re-typing the values in =
a
> different order, not moving the cells.
>
> It sounds like you want the formulas to adjust their references based on t=
he
> location of cell values. Your current structure wouldn't support that, but=

> this might be an approach you could use:
>
> Example:
> A1:D6 contains...
>
> Seq_Name____Amt1___Amt2
> 1___Delta_____4_____40
> 2___Charlie___3_____30
> 3___Bravo_____2_____20
> 4___Alpha_____1_____10
> 5___Echo______5_____50
>
> F2: (a seq to reference....eg 4)
>
> This formula "finds" the Seq from F2 in Col_A and
> returns the associated average of Cols C and D:
> G2:
> =3DAVERAGE(INDEX($C$2:$C$6,MATCH(F2,$A$2:$A$6,0)):INDEX($D$2:$D$6,MATCH(F2=
,$A=AD$2:$A$6,0)))
>
> If you sort the data in descending order by Seq, that formula will still
> find the Seq from F2 in that data and return the same average. In the
> example,
> G2 returns 5.5 before, and after, the sort.
>
> Is that something you can work with?
> --------------------------
>
> Regards,
>
> Ron
> Microsoft MVP (Excel)
> (XL2003, Win XP)
>
> <schla...@airproducts.com> wrote in message
>
> news:1932e92f-e39f-46ed-b593-2c2d0c69f042@e6g2000prf.googlegroups.com...
>
>
>
> > Hi,
>
> > I'm not sure if this problem was solved before so sorry if this is a
> > repeat question. Let's say I have one spreadsheet tab that originally
> > has the following:
>
> > Col A Col B
> > Row 1: 3 3
> > Row 2: 5 5
>
> > In another tab, I have the following formulas that reference the 1st
> > tab:
>
> > Col A
> > Row 1: =3Daverage(A1:B1) - which would yield the number 3
> > Row 2: =3D average (A2:B2) - which would yield the number 5
>
> > Now let's say I resort all the data in the first tab, by col A, in
> > descending order. The first tab now looks like:
>
> > Col A Col B
> > Row 1: 5 5
> > Row 2: 3 3
>
> > All is well enough until you look at the values in the cells in the
> > 2nd tab. The formulas stay the same, but this time they yield 5 for
> > cell A1 and 3 for cell A2. This is not the same values that those
> > cells originally had.
>
> > I had assumed that if I had resorted the cells in one tab, that the
> > formula in the other tab would know what rows to look at when the data
> > got resorted. But, I guess this is not the case. I had tried to avert
> > this problem by using absolute addresses in the formula, but this did
> > not help.
>
> > Does anyone know a way to code the formulas in the 2nd tab, such that
> > they reference the correct rows in the 1st tab? While I have presented
> > a simple example, the real world example is hundreds of rows long.
>
> > Although I could protect the 1st tab to prevent sorting, I do have a
> > periodic need to resort. The 1st file contains a list of items and
> > occassionally, I need to resort in alpha order.
>
> > Any help would be greatly appreciated.
>
> > Thanks,
> >Scotty81- Hide quoted text -
>
> - Show quoted text -

Ron,

Yes, thanks - that does do the job.  I've worked in Excel for some
time, but have not had the experience of working with the Match and
Index formulas.  The only unfortunate part is that it would make the
AVERAGE formulas more lengthy.  That formula was just a simpler
example of what I do with some of the numbers.  However, it does make
the 2nd tab guaranteed to return the correct value regardless of the
sort order.

Thanks again,
Scotty81
0
schlagce (3)
3/7/2008 2:35:30 AM
I'm glad you could use that.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

<schlagce@airproducts.com> wrote in message 
news:3448ce32-e508-4f4f-877d-bb2f6e986cb2@s12g2000prg.googlegroups.com...
On Mar 6, 7:55 am, "Ron Coderre" <ronREMOVETHIScode...@bigfoot.com>
wrote:
> The formulas you're using are referencing the cells....independent of the
> values they contain. Sorting is the equivalent of re-typing the values in 
> a
> different order, not moving the cells.
>
> It sounds like you want the formulas to adjust their references based on 
> the
> location of cell values. Your current structure wouldn't support that, but
> this might be an approach you could use:
>
> Example:
> A1:D6 contains...
>
> Seq_Name____Amt1___Amt2
> 1___Delta_____4_____40
> 2___Charlie___3_____30
> 3___Bravo_____2_____20
> 4___Alpha_____1_____10
> 5___Echo______5_____50
>
> F2: (a seq to reference....eg 4)
>
> This formula "finds" the Seq from F2 in Col_A and
> returns the associated average of Cols C and D:
> G2:
> =AVERAGE(INDEX($C$2:$C$6,MATCH(F2,$A$2:$A$6,0)):INDEX($D$2:$D$6,MATCH(F2,$A�$2:$A$6,0)))
>
> If you sort the data in descending order by Seq, that formula will still
> find the Seq from F2 in that data and return the same average. In the
> example,
> G2 returns 5.5 before, and after, the sort.
>
> Is that something you can work with?
> --------------------------
>
> Regards,
>
> Ron
> Microsoft MVP (Excel)
> (XL2003, Win XP)
>
> <schla...@airproducts.com> wrote in message
>
> news:1932e92f-e39f-46ed-b593-2c2d0c69f042@e6g2000prf.googlegroups.com...
>
>
>
> > Hi,
>
> > I'm not sure if this problem was solved before so sorry if this is a
> > repeat question. Let's say I have one spreadsheet tab that originally
> > has the following:
>
> > Col A Col B
> > Row 1: 3 3
> > Row 2: 5 5
>
> > In another tab, I have the following formulas that reference the 1st
> > tab:
>
> > Col A
> > Row 1: =average(A1:B1) - which would yield the number 3
> > Row 2: = average (A2:B2) - which would yield the number 5
>
> > Now let's say I resort all the data in the first tab, by col A, in
> > descending order. The first tab now looks like:
>
> > Col A Col B
> > Row 1: 5 5
> > Row 2: 3 3
>
> > All is well enough until you look at the values in the cells in the
> > 2nd tab. The formulas stay the same, but this time they yield 5 for
> > cell A1 and 3 for cell A2. This is not the same values that those
> > cells originally had.
>
> > I had assumed that if I had resorted the cells in one tab, that the
> > formula in the other tab would know what rows to look at when the data
> > got resorted. But, I guess this is not the case. I had tried to avert
> > this problem by using absolute addresses in the formula, but this did
> > not help.
>
> > Does anyone know a way to code the formulas in the 2nd tab, such that
> > they reference the correct rows in the 1st tab? While I have presented
> > a simple example, the real world example is hundreds of rows long.
>
> > Although I could protect the 1st tab to prevent sorting, I do have a
> > periodic need to resort. The 1st file contains a list of items and
> > occassionally, I need to resort in alpha order.
>
> > Any help would be greatly appreciated.
>
> > Thanks,
> >Scotty81- Hide quoted text -
>
> - Show quoted text -

Ron,

Yes, thanks - that does do the job.  I've worked in Excel for some
time, but have not had the experience of working with the Match and
Index formulas.  The only unfortunate part is that it would make the
AVERAGE formulas more lengthy.  That formula was just a simpler
example of what I do with some of the numbers.  However, it does make
the 2nd tab guaranteed to return the correct value regardless of the
sort order.

Thanks again,
Scotty81 


0
3/7/2008 2:38:07 AM
Reply:

Similar Artilces:

Where's the Sort by New Message option?
Not sure when the layout of the newsgroups changed but I can't seem to find the ability to sort by new message in a thread instead of sorting by just the original thread date. That was hugely helpful as I could follow along and see what threads were still active. If you're gonna hang around in the newsgroups (any newsgroups), you may want to start using a newsreader. Microsoft Outlook Express can do it for you. Saved from a previous post: You may want to connect to the ms newsserver directly: If you have Outlook Express installed, try clicking on these links (or copy and paste i...

The one source for SEO Services
After using 10 different seo companies over the last 2 years for all my sites the only one that got me the conversion rates like I wanted was http://www.atomicsearchengineoptimization.com Atomic SEO. Really, I thought their prices were outstanding, by that I mean expensive but after two months of service, it was worth every dollar. Here is their pricing, http://www.atomicsearchengineoptimization.com/Monthy_plan_rates-seo-services.html How do you think their rates compare? ...

Sorting
Hi, is it possible to use variable for sorting? Something like: declare @sort varchar(10) SET @sort='column1 DESC' SELECT ROW_NUMBER() OVER (ORDER BY @sort)AS rowId, * FROM table Is dynamic SQL only option? Thank you, Simon On 15/04/2010 11:28, simon wrote: > Hi, > > is it possible to use variable for sorting? > > Something like: > > declare @sort varchar(10) > SET @sort='column1 DESC' > > SELECT ROW_NUMBER() OVER (ORDER BY @sort)AS rowId, * FROM table > > Is dynamic SQL only option? You can use CASE to he...

How to sort account list?
I'm using MS Money 2004 Small Business. In the account list, my accounts are catagorized by and in this order: - bank accounts - credit accounts - investment accounts - loans and liabilities - asset accounts TOTAL BALANCE In the above view, I cannot easily determine totals for assets and liabilities. The following view does this. - bank accounts - investment accounts - asset accounts SUBTOTAL -loans and liabilities SUBTOTAL TOTAL BALANCE How do I get the above view? Thanks, Brett I don't use Small Business. But you can run a Net Worth report to get total assets and ...

Row names will not move with sort
Each row in my summary table in Sheet1 is hyperlinked to a corresponding table in Sheet2 with additional details. I need to move the rows in my summary table (Sheet1) and preserve the links to and from the details tables (Sheet2). I found that I can move rows in Sheet1 with cut & insert and the hyperlinks are maintained. I can travel from a row in summary table (Sheet1) to details table (Sheet2) and back, even after the corresponding row (Sheet1) was moved. But if I sort the rows in Sheet1 the links from Sheet2 back to corresponding rows in Sheet1 lead to presorted locations. Apparen...

Formula to return the name of a tab?
We have a spreadsheet set up that pulls the minimum value from several different tabs. We are looking for a formula or a way to display, in the next column, which tab that minimum value came from. Does anyone have any ideas? You might check the Help files for information on the SHEETNAME function. Ed "Amanda" <anonymous@discussions.microsoft.com> wrote in message news:54F7CB4F-A621-4DB0-9963-56F0406EE8F1@microsoft.com... > We have a spreadsheet set up that pulls the minimum value from several different tabs. We are looking for a formula or a way to display, in the next...

sorts not sorting
OK- Thanks to everyones help I now i have a list i can work with... but there are a few problems.... the zips are all 5 digit and now i have to sort them... the problem is, THEY WONT SORT CORRECTLY!!!!!!! The numbers are not in order... some are but a lot are not... is there anyway to fix this???? i need to sort them by zip code but cant seem to get them to do it correctly.. any ideas??? ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ You are going to be far better of...

import- number- sort?
I imported this data into a spread sheet- I tried to format it to number, but when I sort it- I get : 37.08 4.33 4.79 4.8 42.56 5.94 Whats up with this? Thanks Brent Hi Brent, Install the TrimAll macro, select the column and invoke the macro from Alt+F8 http://www.mvps.org/dmcritchie/excel/join.htm#trimall Directions to install and use a macro at http://www.mvps.org/dmcritchie/excel/getstarted.htm#havemacro I expect that you have spaces or CHAR(128) "Required Blank" characters in you data you can check is =LEN(A1) --- HTH, David...

Set Tab Order
Is their a way to set the tab order in an Excel spreadsheet when I have protected the sheet - so you skip over locked cells to get to only the uprotected cells? Hi in the protection dialog uncheck 'select locked cells' -- Regards Frank Kabel Frankfurt, Germany <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag news:13a4701c44434$ad8773a0$a301280a@phx.gbl... > Is their a way to set the tab order in an Excel > spreadsheet when I have protected the sheet - so you skip > over locked cells to get to only the uprotected cells? ...

Can't remove non existent tape library from DPM Management tab
We had an autoloader to die a few weeks back which we removed and replaced with a new unit. After following the instructions to bring the new unit on line (rescan, etc.) I now see the new autoloader under the Management -> Libraries tab (cool!). However, I also still see the old unit as well in the "offline" state. I want to remove the old unit but I can't see any way to do this from the DPM management console. What is the best way to remove the old (dead) autoloader from DPM? Thanks! Jeff Hi Jeff, DPM will list offline libraries if any protection group...

date formula #2
Hi i am trying for a way to work out how i can formulate the date, ie. if today is 17 November 2003, i want to import data from date 1 Novemeber 2003 how would i do this and what formulae would i use? any idea ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com =today()-1 GB "jaggosai" <jaggosai.x32sz@excelforum-nospam.com> wrote in message news:jaggosai.x32sz@excelforum-nospam.com... > > Hi i am trying for a way to work out how i can formulate the dat...

video on One Note
The picture is kind of psychedelic... while all other applications and tv work fine on my pc... Do I need a special codec? ...

Easiest way of handling multiple checks with one deposit
I am fairly new to Microsoft Money (using 2007), but it is working out very well for me. The only thing I am currently trying to figure out is the best/easiest way to handle things when I make a deposit with two or more checks at once. I am having Money sync with my bank, and any deposit (regardless of the number of checks) is treated as a single entry. I have seen a few references to using some sort of secondary account, but it seems like a fairly round-about way to handle it. Are there any alternatives methods known? Thank you for any information. In microsoft.public.money, Matt wr...

sorting macro #3
I need to sort on 8 cells in a row and on 1500+rows. I can do it one at a time but I know there must be an easier way. Can ANYONE HELP? C3:J3 I need these cells sorted and then down to C1532:J1532 I did create a macro to sort after I selected them but still one at a time. Does it have to be a macro? I can edit a macro but don't really know how to program them. Yes, it has to be a macro. The following should do it. This macro loops through all the entries in Column C, and in each row it sorts the values in Columns C:J. HTH Otto Sub SortRows() Dim rColC As Range Dim i As...

2 cash drawers, one closing ????
We have a POS computer with 2 cash drawers, since its two cashiers that works the station at the same shift. My question is, is there a way to have 2 closing? one per cash drawer / cashiers? This sins since both cash drawers are in the same shift and both start with a petty cash. Whats the recommended way to work a shift with 2 cash drawers/cashiers and to properly square off the shift? ...

Can we sort a form and also be able to enter new records.
Hi, It is possible to sort the data on a form and also be able to enter new and edit the existing records in it. Cheers! On Tue, 15 Jan 2008 15:41:16 -0800 (PST), Rex wrote: > Hi, > > It is possible to sort the data on a form and also be able to enter > new and edit the existing records in it. > > Cheers! I assume you mean "Is it". The form sort order has nothing to do with editing or adding new records, so the answer is yes. If you cannot edit or add new records, make sure the form's record source, if it is a query, is updateable. Some queries are not. O...

Auto-entering data from another sheet
Hello all, Hopefully someone can help me. I am wanting to automatically enter data from one sheet into the next by a text prompt. For example: On sheet 2 I will have 3 static columns that will have data entered in the format: text / text / number respectively. On sheet one I want to be able to enter the text from the first column on sheet two and have excel automatically fill in 2 other cells with the data from cell B and C from sheet 2. For example: Sheet 2 contains hello / how / 123 in row 1 and column A,B,C. I enter: hello (on sheet 1 cell A) and in cell B and C I automatically get...

Sorting checking register
How do i sort my check register in Money 2004 Deluxe so that uncleared transactions appear below cleared transactions? In Quicken i could click on the column to provide that sort. In microsoft.public.money, Dean wrote: >How do i sort my check register in Money 2004 Deluxe so >that uncleared transactions appear below cleared >transactions? In Quicken i could click on the column to >provide that sort. You don't. Available choices are chosen by clicking View at the top of the register. ...

Which formula to match string subset?
I'm being obtuse today and can't figure out which formula to use to match the beginning portion of a string. For instance, in a SUMPRODUCT or IF statement I need to be able to identify just those records where the first few characters of value in cell within a named range matches what is specified in the formula. Named Range = Freight Named Range=FtChg GR1234 125.00 2D9879 300.00 GR3467 50.00 SA0009 285.00 GR0099 ...

using addrress books to sort incoming mail
I use address books to sort incoming mail. An odd thing: depending on how the sender's name comes across, it doesn't get caught by the filter (amd moved to the "Family Mail" Folder I have set up. for example: my mom and dad's email (from momanddad@somedomain.com) comes as from that address. However, in my contacts, they are listed by their names: John and Mary Smith, with momanddad@somedomain.com as their email address and John and Mary Smith as the display name. What have I done wrong? TIA 1. The big ONE - failed to post your version of Outlook. Rules operate at ...

How to paste a data file into a spreadsheet including formulas?
I use Excel 2000, and I have a spreadsheet that I have been updating by hand. The data is getting fairly large now, so I am in the process of writing a perl script to generate a text file containing the data, separated by tabs, so that I can just copy everything in the text file and paste it into the spreadsheet. The spreadsheet does have some columns that do some arithmetic calculations. I can easily have the perl script perform those calculations itself, so that all the values in the text file are "hard coded". But the problem is that there will be a few errors in my data strea...

Visible tab threw drop down selection
Hello, I want to have a main tab that I would select an employees name from a drop down list "The employee name would be the name of a tab" Then it would make the tab visible then I would have a button to close or make it visible = false again and only show the main screen where I need to select an employee. How would I acomplish this? Thanks! One way to accomplish this is in three steps: 1. Create a validation list of employees using Data->Valication... Under "Allow" select "List" and select the range of your employee names 2. Paste the followin...

Unmerge so I can sort
I coy/pasted data into Excell and when I try to sort it I get "This operation requires merged sells to be identically sized". I understadn the work around in KB but how do I find which sells are merged? I wouldn't bother looking. I'd just remove all the merged cells from the range to sort. Select that range format|cells|alignment tab uncheck the merge cells box But if you wanted to search, you can do it via process of elimination. Select a range, format|cells|alignment tab. If that merge cells box is checked, then the whole selection is merged. If it's grey, t...

Is it possible to host one domain in two servers?
Hello all, I'm currently working on adding a new server in a new branch location. Right now I have SBS 2003 and it's working fine. The people in the branch will just VPN in to retreive their emails. As that branch grows, there's a need for a faster email. I'm planning to add a new Exchange server on that branch machine. Is there a way to separate mailboxes to two different servers under one domain? For example: person1@domain.com will go to server1.domain.com and person2@domain.com will go to server2.domain.com. Thanks, Jerry Generally speaking, yes, Exchange definitely al...

[ANN] Share one account with multiple users and/or computers
PROBLEM: * You are in a situation where two or more people check the same account but have problems knowing who has acted on the message(s) or see a flagged message for your attention. This is further complicated by platform and email application (e.g. Outlook, Entourage and Apple mail). * You are the only user but access your account from multiple computers. Continue reading for the solution along with info on IMAP and POP accounts as well as IMAP providers: Share one account with multiple users and/or computers (The Entourage Help Blog) <http://blog.entourage.mvps.org/2009/01/share...