Excel Woes
Author
Discussion

loosemarbles

Original Poster:

1,863 posts

230 months

Friday 24th April 2020
quotequote all
Hoping someone can help!

I created a quite complex Excel sheet, which was working fine, until someone else got their hands on it. It appears that they have sorted a sheet incorrectly, so a lot of formulae don't match up anymore.

In it's most basic form, a formula will look like:

=inFEED!T618

I know what row number should be used for each, but given we are talking about 700 rows, and up to column AM, I'm not minded to re-type it all. I cannot just correct one row and copy down, as the data isn't in the same order in the original data.

If I had the correct row number in cell AN23 for example, is there a way of getting the above formula to look at it, and intepret the correct column that it should look at? I.E.

=InFEED!T(AN23)

And, so that in every column, it adapts to the correct column?


Troubleatmill

10,210 posts

190 months

Friday 24th April 2020
quotequote all
loosemarbles said:
Hoping someone can help!

I created a quite complex Excel sheet, which was working fine, until someone else got their hands on it. It appears that they have sorted a sheet incorrectly, so a lot of formulae don't match up anymore.

In it's most basic form, a formula will look like:

=inFEED!T618

I know what row number should be used for each, but given we are talking about 700 rows, and up to column AM, I'm not minded to re-type it all. I cannot just correct one row and copy down, as the data isn't in the same order in the original data.

If I had the correct row number in cell AN23 for example, is there a way of getting the above formula to look at it, and intepret the correct column that it should look at? I.E.

=InFEED!T(AN23)

And, so that in every column, it adapts to the correct column?
Mail it over - and I'll have a look this afternoon. Drop me a PM. smile


Also - have a look at the INDIRECT function.

Mr Pointy

13,420 posts

190 months

Friday 24th April 2020
quotequote all
If you know what the row number should be can't you type that in to a new column (I know, it's 700 entries) & sort on that new column?

loosemarbles

Original Poster:

1,863 posts

230 months

Friday 24th April 2020
quotequote all
I would send it on, but that would be frowned upon.

The challenge is that each row probably has 20 columns which are related to the row number on the original sheet. I know the row number, having extracted that, but the issue is getting each cell to use the correct number.

I.E. In Columns A-D, the formula should look like: =inFEED!A2, to =inFEED!D2, but they actually are =inFEED!A106, to =inFEED!D106

Troubleatmill

10,210 posts

190 months

Friday 24th April 2020
quotequote all
loosemarbles said:
I would send it on, but that would be frowned upon.

The challenge is that each row probably has 20 columns which are related to the row number on the original sheet. I know the row number, having extracted that, but the issue is getting each cell to use the correct number.

I.E. In Columns A-D, the formula should look like: =inFEED!A2, to =inFEED!D2, but they actually are =inFEED!A106, to =inFEED!D106
EDIT... Simplified answer below.

In cell G2 ( in my example...) type in =INDIRECT("inFeed!A"&F2)





And the data on your sheet inFEED.


Edited by Troubleatmill on Friday 24th April 14:06

Troubleatmill

10,210 posts

190 months

Friday 24th April 2020
quotequote all
Although copy columns A to D to a new sheet - Sort by the column number you want and paste back - might be the easier approach.

Troubleatmill

10,210 posts

190 months

Friday 24th April 2020
quotequote all
Or this way.
Assuming the row you want is in cell F2.

Type this into cell H2 =INDIRECT(MID(FORMULATEXT(A2),2,8)&F2)

sideways sid

1,467 posts

246 months

Friday 24th April 2020
quotequote all
The other aspect of this is to reduce the chances of repetition due to somebody sorting the datasheet and thus messing up the output sheet. Several ways to address this depending on the operating environment, including:
explore protecting the data worksheet so that it can't be sorted
perhaps ensure it can only be opened as 'Read-Only' so any sorted versions are saved as something else
add a message box on opening, suggesting the operator opens the output workbook too
put the two together in the same workbook
etc etc

Mr Pointy

13,420 posts

190 months

Friday 24th April 2020
quotequote all
loosemarbles said:
I would send it on, but that would be frowned upon.

The challenge is that each row probably has 20 columns which are related to the row number on the original sheet. I know the row number, having extracted that, but the issue is getting each cell to use the correct number.

I.E. In Columns A-D, the formula should look like: =inFEED!A2, to =inFEED!D2, but they actually are =inFEED!A106, to =inFEED!D106
Any chance you can copy the first 20 rows or so & sanitise the data so we can have a play with the problem?

loosemarbles

Original Poster:

1,863 posts

230 months

Friday 24th April 2020
quotequote all
Troubleatmill said:
In cell G2 ( in my example...) type in =INDIRECT("inFeed!A"&F2)
I think this works! Just testing it now.

MOBB

4,589 posts

158 months

Friday 24th April 2020
quotequote all
Indirect is such a lovely thing

paul.deitch

2,317 posts

288 months

Friday 24th April 2020
quotequote all
Use a database instead!

OlonMusky

708 posts

85 months

Friday 24th April 2020
quotequote all
paul.deitch said:
Use a database instead!
ah shush

paulrockliffe

16,629 posts

258 months

Friday 24th April 2020
quotequote all
paul.deitch said:
Use a database instead!
Excel sorted this by adding PowerPivot.

OP, load your data into the Data Model, create the relationships between your tables and then create whatever output you want with a Pivot Table connected to the Data Model.

If that's not enough, they also added PowerQuery which will let you turn your data into whatever tables you need to draw whatever Pivot Tables.

It's 2020 now folks, Formulas in Excel are now for emergencies only.

OlonMusky

708 posts

85 months

Friday 24th April 2020
quotequote all
paulrockliffe said:
paul.deitch said:
Use a database instead!
Excel sorted this by adding PowerPivot.

OP, load your data into the Data Model, create the relationships between your tables and then create whatever output you want with a Pivot Table connected to the Data Model.

If that's not enough, they also added PowerQuery which will let you turn your data into whatever tables you need to draw whatever Pivot Tables.

It's 2020 now folks, Formulas in Excel are now for emergencies only.
Am I missing some posts from this thread? I think I clearly must as your advice (and the earlier advice to use database instead) would suggest that OP provided a description of what the data set is about, what's its use, who's the audience, how it's consumed.

paulrockliffe

16,629 posts

258 months

Saturday 25th April 2020
quotequote all
OlonMusky said:
paulrockliffe said:
paul.deitch said:
Use a database instead!
Excel sorted this by adding PowerPivot.

OP, load your data into the Data Model, create the relationships between your tables and then create whatever output you want with a Pivot Table connected to the Data Model.

If that's not enough, they also added PowerQuery which will let you turn your data into whatever tables you need to draw whatever Pivot Tables.

It's 2020 now folks, Formulas in Excel are now for emergencies only.
Am I missing some posts from this thread? I think I clearly must as your advice (and the earlier advice to use database instead) would suggest that OP provided a description of what the data set is about, what's its use, who's the audience, how it's consumed.
No, pretty much any data that is using formulas that break when another table is sorted would be better structured in a relational format, even if it's very simple.

The OP has some data in a table and is creating another table that also contains some data and there is a relationship between the two. If he treats the two tables as source data and then creates his combined table as a Pivot off a proper relational structure he won't need formulas at all in places where his users can break them by sorting the table. And sorting the table is the sort of thing that users should be allowed to do unless there's a really good reason for them not to as broadly, if you tell them not to sort the table they'll come back asking for another table that is how they wanted it.

Doing it properly will insulate the data from the users to a significant extent as well as bringing a load of other side benefits around the user experience and flexibility too. (It also lets you work with tables with more than a million rows, gives you access to a better analytical engine in Excel and gives you a fighting chance of doing proper analysis without gumming your spreadsheet up and creating an unsupportable mess)

Excel makes that all pretty trivial, though it doesn't make it very obvious that that's what all that stuff in that ribbon you've never looked at is for. Once you know what you're aiming at, a bit of Google around PowerPivot, PowerQuery and Relationships and it's much easier than messing around with formulas.

I say this as a data analyst that pulls together huge quantities of data in Excel that hasn't written a formula in a table in a couple of years. I think I only use them to create dynamic titles that follow slicer selections.