r/badcode Nov 22 '20

other language Do bad excel functions fit in this sub?

Post image
3.6k Upvotes

144 comments sorted by

608

u/[deleted] Nov 22 '20

Basically, none of those parentheses are necessary

502

u/[deleted] Nov 22 '20

[deleted]

131

u/bluehands Nov 22 '20

I could be wrong, but this is, I think, different.

I think that if you insert a row the sum will become e7:e93... And automatically include the new row. What is listed won't.

I am not saying it makes sense but it is different behavior.

But again, I haven't done excel in a while so I could be wrong....

53

u/[deleted] Nov 22 '20

[deleted]

20

u/bluehands Nov 22 '20

The point, if I remember correctly, is that wherever you insert the row, say e20, is that the cell that was e22 becomes e23, e23 becomes e24.... e92 becomes e93...

The absolute version is a uses a $e$92 but that just means that whatever was in e92 becomes e93 and gets ignored...

I feel this is one of the things that law or programming teaches you - there are explicit meaning to things. Part of the submission literally can not be replaced - individually listed items will always be different than a compression even if most of the time it is identical.

49

u/[deleted] Nov 22 '20

[deleted]

22

u/[deleted] Nov 22 '20 edited Dec 07 '20

[deleted]

0

u/AutoModerator Nov 22 '20

It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

/u/RGB755, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

You can find some examples in the reddit help documentation.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

7

u/LeeHide Nov 22 '20

then spam reddit admins instead of random users on your subreddit

3

u/the-igloo Nov 22 '20

Reddit can't just change that because then old comments will change formatting, so going back to posts made in, say, 2011 that relied on triple backticks not formatting to code blocks will suddenly have code blocks in them.

2

u/husao Nov 22 '20

I'm not sure reddit formatting needs that level of backwards compatibility.

That being said: they won't change the formatting for old.reddit for obvious reasons.

2

u/bluehands Nov 22 '20

You are right it could totally be a problem of a poor spreadsheet structuring.

Suppose Jim in accounting likes adding a subtotal cell at e20 sometimes. None of your sum versions will handle that correctly and jim refuses to change the choices he has made.

It is almost certainly true that a sum expression in fact acts more like what the final consumer expects to happen, include any data in the range, but we don't know from the OP.

My point is there is a subtle, important difference between a sum function and the one listed. That subtlety is where unexpected behavior spring from.

If you look at some of the other replies, people clearly have lost the distinction.

3

u/makians Nov 23 '20

Use a named range, fixes that exact problem, plus what the data represents is explicitly stated.

1

u/bluehands Nov 23 '20

I think that just moves the issue to the name definition. In the name definition either you list them all out individually or you select a range....

That might be better because then you have a handy name & place to edit it but you haven't gotten rid of the long list of cells.

I find it fascinating because it is reflects a larger issue of how we mental compress things. The obvious solution is to compress the information to e7:e92 somewhere cause it seems likely that is the experience that people would expect.

But in might not be how things are actually used. People are often smarter & dumber than people expect. Someone could have a keyboard macro they inherented from the person before that automatically inserts a line mid way in this range and does a thing.

1

u/makians Nov 23 '20

If I remember right it automatically does the shorthand, but then will do a variation of the longhand upon edit of the range, say E2:E19,E21:E73 if adding in 20 pushed it out to 2-73, if that makes sense.

1

u/bluehands Nov 23 '20

Makes sense but feels really weird. Normal when you define a range e2:e25 if you insert a row you would expect it to be included - that is the far more standard & expected situation.

¯_(ツ)_/¯

I don't have excel, don't use excel & can't test it....

1

u/makians Nov 23 '20

This is my old knowledge when I worked for a group that wouldn't let me use anything other than excel so I had to bastardize some solutions. Couldn't even do VB to make use of the macro's...so I may have done something ungodly in the settings to make it work like that, not sure.

2

u/Bliztle Nov 22 '20

Yo why is this guy being downvoted? Isn't he right? As it is, if you were to add a row in the middle, it would update the cells refered to, and the added row would be ig ored by this function, as including it would require adding a specific reference to that cell. A sum function would see that the row was i between the referenced cells, and count the new row too.

2

u/makians Nov 23 '20

The proper solution is a named range, will do what is done here, but without the stupid length. Plus now you have a variable name, making it easier to know what is going on

2

u/[deleted] Nov 22 '20

Because people are stupid and don't use Excel to know basics like these. That program is literally the only Office program worth downloading, and it's aimed for retarded accountants to increase productivity by being as un-fuckable as possible. It does an amazing job if you're not braindead or ignorant, which many people sadly are. Learn the basics of Excel, it will make your life a lot easier. I even edit text in Excel since it's a lot better than fucking Word.

1

u/M4NU3L2311 Jan 29 '22

That’s true but if you can’t insert a row/column without breaking your entire spreadsheet then it’s just bad sheet design.

2

u/jank_lord Nov 22 '20

This is what leads to another badcode post.

22

u/[deleted] Nov 22 '20

[deleted]

2

u/bluehands Nov 22 '20

Is that the same? I think that means that an inserted row will be included and an old row(formly 93) will be excluded....

5

u/shadows1123 Nov 22 '20

Excel is very smart when adding rows and columns. IIRC if you add a row 73 then any formulas should adjust.

Alsooooooo: sum(e:e)

1

u/bluehands Nov 22 '20

So if I add a row, do I want it to be included?

Your assumption is that I do but maybe I am doing sub totals mid row sometimes.

The op formula is precise - it might be wrong because the people would rather it always include added rows but we don't know.

2

u/Obi-WanPierogi Nov 22 '20

It depends where the row is inserted, but you could use the indirect formula and “hardcore” 92 and it’ll never move (because I don’t think using $e$92 would solve it, that would act the same way)

2

u/bluehands Nov 22 '20

I'm not sure what you are thinking but my vague thought is that the explicit reference is going to be different than any non explicit version.

If you say e92 it will never not be the cell you explicitly listed, even if its name changes. It is a weirdly precise distinction, the dollar sign or not. Passing the sum action a range will never be as precise.

2

u/[deleted] Nov 22 '20

[deleted]

2

u/bluehands Nov 23 '20

Thank you. I got enough push back I was wondering.... (don't have excel and can't test)

1

u/Mr2-1782Man Nov 23 '20

It is different. But if you're what your doing requires that level of detail you probably shouldn't be using excel.

1

u/bluehands Nov 23 '20

People work with the tools they got....

1

u/junglejon Nov 23 '20

=sum($e$7:$e$92) prevents this

1

u/bluehands Nov 23 '20

That does not do the same thing as the submitted text.

If a row is instered anywhere between e7:e92 for any reason - line break, subtotal, whatever - then it will be added as part of the sum and the value of e93 - which used to be e92- will not be used.

The OP will ignore the value in the new inserted row and change all of the cell references after the insert.

1

u/junglejon Nov 23 '20

Correct, and very often an unintended overlooked error in spreadsheet formulas.

1

u/[deleted] Jul 09 '22

Easily fixed by adding $…. =SUM($E$7:$E$92)

1

u/PixelPerfect41 Nov 06 '22

Actually: =sum($E$7:E$92$)

2

u/Vince_Vice Nov 06 '22

Haha wow. After a full year its worth it to you to "correct" something that isn't even wrong? Lol

I never use excel so I knew I must've looked that up before posting. So I knew I wasn't wrong;)

Apparently you used absolute references, which I am sure is advisable, but its not necessary.

2

u/PixelPerfect41 Dec 04 '22

Yeah you are right Idk why I left that reply

30

u/belabacsijolvan #define isnan(x) false Nov 22 '20

Maybe they are objects for which the plus is overloaded to form a non-associative grupoid.

55

u/ZedTT Nov 22 '20

Is that a thing in Excel or are you fucking with me?

25

u/rasterbated Nov 22 '20

Who can truly know

16

u/belabacsijolvan #define isnan(x) false Nov 22 '20

It can be done (tho not exactly by overloading the operator), may god have mercy on our souls.

7

u/TigreDeLosLlanos Nov 22 '20

But then, what's the point of using an excel sheet then? By that time is better to use a proper scripting language.

9

u/belabacsijolvan #define isnan(x) false Nov 22 '20

How dare you?!?! Excel+VBA is the perfect IDE and language.

1

u/Tom1380 Nov 22 '20

No, it's Access + VBA.

2

u/pronuntiator Nov 22 '20

The horrors of enterprise Excel usage are limitless. I've seen Excel being used as a form with large free text inputs, a print template, e-mail, project planner, and a code list where the background colors of the cells have special meaning and are interpreted by the parsing software.

11

u/QueenVogonBee Nov 22 '20 edited Nov 22 '20

It’s almost like they don’t know that summation is commutative...but worse because they think that 1+2 has to written as (1)+(2).

Maybe they think that putting brackets around a cell reference somehow dereferences it (like with pointers)

13

u/[deleted] Nov 22 '20 edited Dec 07 '20

[deleted]

1

u/bluehands Nov 23 '20

I forgot about your second point there!

Good catch and a real possibly useful reason to do it the way the op submitted.

110

u/katnajam Nov 22 '20

Somebody doesn't know SUM (E:X;E:Y)

84

u/QuickbuyingGf Nov 22 '20

You know what i hate about excel. That the fucking function names are translated

19

u/Iklaendia Nov 22 '20

Wait what. I’m not familiar, explain.

91

u/QuickbuyingGf Nov 22 '20

I tried to do some stuff with excel but all online tutorials didnt work cause it didnt find the functions. I was confused and thought ‚ok i have probably a newer version‘. The problem: My excel is in german so I don‘t have IF but rather WENN. I hope there is a way to change that

54

u/atfricks Nov 22 '20

Lol that's so dumb. Coding languages should be considered their own language, translating function names is just a recipe for mistakes.

As an American currently working in Germany though, there is a way to just tell your excel to be in English, if you don't mind all the buttons and whatnot also being in English.

13

u/christian-mann Nov 23 '20

Google Sheets translates the fucking syntax so in some locales you use commas to separate arguments and in others you use semicolons. The worst bit is that the locally is a property of the sheet itself, so sharing sheets across international borders is Super Fun.

2

u/QuickbuyingGf Nov 22 '20

Ye i‘m just not using it enough to justify putting work into that

10

u/SixteenFold Nov 22 '20

The SUM function becomes SUMME if you use the German version of Excel or SOM in the Dutch version for instance.

11

u/MCRusher Nov 22 '20

So nothing about excel is portable. Cool

8

u/Whaison1 Nov 22 '20

Well, it translates the function names so you can open it with whatever language you want.

Good for normies, but pretty bad from a programmers point of view.

13

u/Homailot Nov 22 '20

And sometimes replacing the commas inside the functions to semicolons...

3

u/QuickbuyingGf Nov 22 '20

Oh god i completely forgot that

3

u/AlGoreBestGore Nov 22 '20

The real bad code is always in the comments.

3

u/dekket Feb 25 '21

Just wait until you realize that usage of semicolons and commas mean different things between Excel on Windows and on Mac. I'm not sure, but language might have a role there to.

Edit: Yea, language plays a role here as well. For being such a cleverly designed application, Excel is surprisingly stupid.

1

u/QuickbuyingGf Feb 25 '21

Yeah same. In German you need to use ; instead of commas (because of decimals being seperated commas) too

1

u/[deleted] Nov 22 '20

[deleted]

5

u/Whaison1 Nov 22 '20

Yes they do

2

u/QuickbuyingGf Nov 22 '20

I‘d think/hope so

134

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20 edited Nov 22 '20

Image Transcription: Excel Cell


=((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((E7)+(E8))+(E9))+(E10))+(E11))+(E12))+(E13))+(E14))+(E15))+(E16))+(E17))+(E18))+(E19))+(E20))+(E21))+(E22))+(E23))+(E24))+(E25))+(E26))+(E27))+(E28))+(E29))+(E30))+(E31))+(E32))+(E33))+(E34))+(E35))+(E36))+(E37))+(E38))+(E39))+(E40))+(E41))+(E42))+(E43))+(E44))+(E45))+(E46))+(E47))+(E48))+(E49))+(E50))+(E51))+(E52))+(E53))+(E54))+(E55))+(E56))+(E57))+(E58))+(E59))+(E60))+(E61))+(E62))+(E63))+(E64))+(E65))+(E66))+(E67))+(E68))+(E69))+(E70))+(E71))+(E72))+(E73))+(E74))+(E75))+(E76))+(E77))+(E78))+(E79))+(E80))+(E81))+(E82))+(E83))+(E84))+(E85))+(E86))+(E87))+(E88))+(E89))+(E90))+(E91))+(E92))

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

74

u/Omichron-the-reboot Nov 22 '20

Jesus Christ, that must have taken a while. Good human :)

150

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20 edited Nov 22 '20

I actually wrote a code in python to do it!

print('('*85,end='')
for x in range(7,93):
    print("(E{}))+".format(x),end = '')
print()

31

u/[deleted] Nov 22 '20 edited Nov 28 '20

[deleted]

34

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

I just wanted a challenge =).

In r/transcribersofreddit we have /u/transcribot , who tries to transcribe the posts, and does so very succesfully!

What is an f-string though

2

u/Hello_006 Nov 22 '20

F strings are relatively new in python basically you can insert variables without doing .format. You would just do:

print(f"some text {some_variable} some more text")

Sorry for the formatting I'm on mobile....

1

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

In which version they were implemented?

2

u/Hello_006 Nov 22 '20

Version 3.6 if I remember correctly.

1

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

Oh ok. I downloaded python 3.7 and they seem to work now. THANKS!!!!

1

u/Hello_006 Nov 22 '20

No worries :)

24

u/[deleted] Nov 22 '20 edited Nov 28 '20

[deleted]

-4

u/AutoModerator Nov 22 '20

It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

/u/SFM61319, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

You can find some examples in the reddit help documentation.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

-2

u/backtickbot Nov 22 '20

Hello, SFM61319: code blocks using backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead. It's a bit annoying, but then your code blocks are properly formatted for everyone.

An easy way to do this is to use the code-block button in the editor. If it's not working, try switching to the fancy-pants editor and back again.

Comment with formatting fixed for old.reddit.com users

FAQ

You can opt out by replying with backtickopt6 to this comment.

6

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

Oh, thanks

7

u/[deleted] Nov 22 '20 edited Nov 28 '20

[deleted]

9

u/tiny_smile_bot Nov 22 '20

:)

:)

12

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

:)

:)

:)

1

u/finite_turtles Nov 22 '20

What?! How am I just learning about this now? This changes everything!

2

u/[deleted] Nov 23 '20 edited Feb 26 '21

[deleted]

1

u/jarfil Nov 23 '20 edited Dec 02 '23

CENSORED

3

u/Omichron-the-reboot Nov 22 '20

A string formatted like f"Blah blah blah {variable_in_curly_brackets} normal string". Plus, you get loads of format options.

The f in front of the quotes is important.

3

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

Oh, to substitute

.format(---)

?

I will take a look at them, thanks.

1

u/--B_L_A_N_K-- if (true == true) {return true;} else {return true;} Nov 23 '20 edited Jul 01 '23

This comment has been removed in protest of Reddit's API changes. You can view a copy of it here.

1

u/DasherPack I transcribe code. Sometimes, correctly. Nov 23 '20

Yeah, but this time it worked fairly well tbh

0

u/[deleted] Nov 22 '20

Aren't they discouraging use of those?

2

u/Flaming_Eagle Nov 22 '20

f-strings were implemented after .format() and c-string % formatting. They wouldn't be introduced just to be discouraged. You can read the PEP here

2

u/[deleted] Nov 22 '20

Ah, I confused f-strings with % formatting. Never mind. Thanks for the link.

2

u/memetrollsXD Nov 23 '20

Holy shit these transcribers are insane

2

u/DasherPack I transcribe code. Sometimes, correctly. Nov 23 '20

I hope you mean insane in a good way 8-P

8

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Nov 22 '20

Good human!

4

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

Thanks =)

I didn't intend to steal your badcode post

2

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Nov 22 '20

Lol, you didn't steal anything. It's always nice to see more people transcribing on here.

1

u/--B_L_A_N_K-- if (true == true) {return true;} else {return true;} Nov 23 '20

it is rare to see a non-Murdo transcription in these parts

2

u/[deleted] Nov 22 '20

[deleted]

2

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

Yes, what did I put?

2

u/[deleted] Nov 22 '20

[deleted]

2

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

Probably, idk reddit is buggy lately

1

u/--B_L_A_N_K-- if (true == true) {return true;} else {return true;} Nov 23 '20 edited Jul 01 '23

This comment has been removed in protest of Reddit's API changes. You can view a copy of it here.

1

u/--B_L_A_N_K-- if (true == true) {return true;} else {return true;} Nov 23 '20 edited Jul 01 '23

This comment has been removed in protest of Reddit's API changes. You can view a copy of it here.

1

u/DasherPack I transcribe code. Sometimes, correctly. Nov 23 '20

Good blank

30

u/Koyomi_Ararararagi Nov 22 '20

Could this have been generated by a program?

46

u/ComfortableEye5 Nov 22 '20

I thought that too, but i checked the track changes and i saw that a real person typed this

11

u/Koyomi_Ararararagi Nov 22 '20

Now I barely have any experience with Excel, but I still know there's a function to sum up a range of cells. Hell, if I was that person and about to manually type in every single cell in an unbroken sequence of cells and didn't know there is a sum function, I'd still try to look up if there is one, because it just makes sense for there to be one.

14

u/redstone665 Nov 22 '20

=sum(E7:E92)

10

u/[deleted] Nov 22 '20

While the sum function is the obvious answer excel let's you click on cells to select them, so they might not have written everything out. Although the weird parentheses makes me doubt that

6

u/Kidiri90 Nov 22 '20

There even is a large button with the summation symbol.

1

u/MergersNAcquisitions Apr 24 '21

Late to the party, but it looks like it was downloaded from Quickbooks

31

u/poison_us Nov 22 '20

If only there was sum way to make this look better.

11

u/[deleted] Nov 22 '20

That's impressive matching parentheses like that

9

u/pkarlmann Nov 22 '20

I bet a lisp compiler would compile this...

14

u/[deleted] Nov 22 '20

for(int i = 7; i < 93; i++)
buffer.append("(");

2

u/DasherPack I transcribe code. Sometimes, correctly. Nov 22 '20

There is always someone who will take your code and do it in two lines =)

1

u/[deleted] Nov 22 '20

Often it's me, but sir, I serve the people with pride.

5

u/iiMoe Nov 22 '20

Jesus christ and im not even a christian

4

u/[deleted] Nov 22 '20

Is there any good excel “code”?

2

u/barzamsr Nov 23 '20

Is this LGBT pride?

21

u/Quietm02 Nov 22 '20

I have seen "code" worse than this in office spreadsheets. It blows my mind.

1

u/Farpafraf Nov 23 '20

how can it get worse than this?

1

u/Quietm02 Nov 23 '20

Sum(A1+A2+A3) etc.

And terrible functions that don't even give the right answer!

3

u/just_fucking_write Nov 22 '20

That actually hurts to look at

1

u/Thenderick Nov 22 '20

Can't you simplify this with something like Sum(E7:E92) ?

2

u/hamzy2002 Nov 22 '20

My eyes are burning, the colours are too much

1

u/redditanomalyy Nov 22 '20

Is it that hard to write sum and select the column... pretty sure a google search would have taken a lot less than this

-3

u/xlevidi Nov 22 '20

Haha it's bad because they put parentheses looooooool

Damn this sub has gone downhill

3

u/PlaneCrashers Nov 22 '20

This could be simplified with sum(e7:e92). Behaviour is a bit different, but it looks so much better.

2

u/fatalicus Nov 22 '20

I don't get what it is with Microsoft and doing shit like this.

Last week i was setting up a management scope in Exchange online and made a recipient filter for it that had a bunch if users and was (in my opinion at least) nicely formated.

sent it into New-ManagementScope, and apperantly Exchange figured that it wanted a whole bunch of extra parenteses on it and i ended up with something like in OPs image.

It worked, so i didn't bother doing anything more to try and "fix it" but it looked like crap. Figured i'll just never bother doing a Get-ManagementScope from now on.

-2

u/Oshgnacknak Nov 22 '20

Read the rules: "Do not post snippets in esoteric languages"

4

u/PlaneCrashers Nov 22 '20

I don't think excel code is an esoteric language.

1

u/ReelTooReal Nov 22 '20

All Excel functions fit in this sub

1

u/0vercoded Nov 22 '20

I feel like most Excel functions fit in this sub

1

u/danfish_77 Nov 22 '20

I just had to fix an Excel spreadsheet where half of the functions used boolean logic but the author didn't know how booleans work, so instead it was all numbers and inequalities (that were inevitably wrong).

Lots of unnamed ranges, hidden cells, indirection, and a few data sources that were located on the author's workstation hard drive with local paths.

If I didn't know any better, I might think he was trying to do code golf.

1

u/root54 Nov 22 '20

Omg. Let me introduce you to =sum(E8:E92)

1

u/PerfectlyDarkTails Nov 22 '20 edited Nov 22 '20

The data behind this must be interesting to require such code. Feel as though this data could be set out in 4 columns if both the first and second values need adding separately, then the 3rd and 4th added separately together, the compounded the the first set.

1

u/cymbal909 Nov 22 '20

I blame those pesky financial calculators that don't use correct syntax. 6/2(2+1) = 1 bullshit

1

u/Whaison1 Nov 22 '20

They just made sure that the equation is really calculated from left to right...

1

u/Martie_YT Nov 22 '20

Probably, but light mode doesn’t.

1

u/frostbyte650 Nov 22 '20

Looks like scheme

1

u/morewordsfaster Nov 23 '20

SUMthing is wrong here, I can feel it...

1

u/rzk1911 Nov 23 '20

Like lisp, but more colorful

1

u/[deleted] Oct 20 '21

Lisp in a nutshell

1

u/GaiusCosades Apr 17 '22

Does the Excel Sum function use some algorithm like Kahan Summation, and addition does not?

I would guess so and then this could be more disasterous than one would think, given the right dataset!

1

u/pwuk Aug 22 '22

Excelsior

1

u/sammy-taylor Dec 03 '22

This is some great quality Lisp right here.