5 ms·
I’m surprised that Excel formulas have such poor coverage in text editors like NP++ or VSCode. Developing horribly convoluted formulas with nested IF statement
by greggsy 4y ago
I’m surprised that Excel formulas have such poor coverage in text editors like NP++ or VSCode. Developing horribly convoluted formulas with nested IF statements in the formula bar is painful, and the PowerQuery editor doesn’t even have syntax highlighting.
Even the ancient built-in VBA IDE has better support.
Surely Excel formulas are the most commonly across the whole population of computer users?
- BiteCode_dev 4y agoYes, but those things have been historically mostly provided by volonteers, and I can understand they didn't want to spend a lot of effort trying to clean the mess of a giant corporation of Microsoft for free. MS should have provided a formulat parser and interpretter as a FOSS portable C lib decades ago. But at the time, they didn't pretend to be the good guys to win market shares, they publically despised anything open or free, so it couldn't happen. I guess it would have help OOo a lot at the time, and would help pandas today. Now that MS has VSCode, maybe they'll end up doing a LSP, but I doubt it. Programmers are not their target for excel.
- galacticdessert 4y agoAs I consultant that works extensively in Excel, I understand your point. The lack of decent syntax highlighting, auto-indentation or “IDE mode” instead of the formula bar can be painful. Especially when working with models developed by others. On the other hand, you can see it as a feature. It forces you to keep your formulas short, break them down in helper columns and overall make your logic cleaner. If you are writing a 4 line long formula, you are doing something wrong. Sytax highlighting would still surely help, but it is not a replacement for clean modelling.
- 2b3a51 4y agoAmateur user of Excel/Calc/Google sheets here. My worst is... =CONCATENATE( IF(A1<0;"-";"+"); TEXT(INT(ABS(A1));"00") ;"d"; IF((ABS(A1) - INT(ABS(A1)) - INT( (ABS(A1) - INT(ABS(A1)))*60 )/60) * 3600 > 59.5; TEXT(INT((ABS(A1) - INT(ABS(A1)))*60)+1;"00"); TEXT(INT((ABS(A1) - INT(ABS(A1)))*60);"00") );"m"; IF((ABS(A1) - INT(ABS(A1)) - INT( (ABS(A1) - INT(ABS(A1)))*60 )/60) * 3600 > 59.5; TEXT(0;"00"); TEXT(ROUND( (ABS(A1)-INT(ABS(A1))-INT((ABS(A1)- INT(ABS(A1)))*60)/60)*3600;0 );"00") );"s" ) ...which should take a value in cell A1 that is in the range [0,360) and return the value in angle notation (degrees, minutes and seconds). I especially wanted this function all in one cell to save loads of helper cells (the spreadsheet calculates the position of the moon, sun, planets and a physical ephemeris for each planet so a lot of angles to display). It is a pain to apply, I use a text editor to search and replace the cell reference for each angle. I'd settle for the formula bar display of the formula not reformatting the line breaks.
- ReactNative22 4y agoYou could put that into a VBA formula, although it wouldn't be as fast unfortunately (as I learned when I tried simplifying excel formulae - which are _compiled_ whereas VBA I think is interpreted? - in any case, excel was like 50x faster for me). I assume you have tried the '$' signs to see if they will help?
- 2b3a51 4y agoThanks for reply. Yes, if it was just for Excel I'd make a user defined function that returned a text value. I wanted the formula to work the same on Libre/Open office and on Google sheets so I went for an actual spreadsheet formula. Actually, the ';' separator came from the LibreOffice version. '$' signs for A1? I'd still need to search and replace for A1 each time I needed to convert an angle in a different cell but I take your point that I could move the output around more easily. Speed does not seem to be an issue (the rest of the spreadsheet has calls to trig functions by the score)
- leipert 4y agoIf you prepend the column/row with a dollar, it is locked when you drag and extend. e.g. $A1 locks the column, A$1 the row and $A$1 both Can be pretty helpful if you put a constant somewhere.
- 2b3a51 4y agoThanks for your reply. I am aware of the absolute cell reference notation and use it frequently when I have a set of constants (e.g. longitude, latitude, year, month, day, timezone &c) that are referenced in many formulas. However the situation in my post was the other way round sort of. As a concrete example (just in case I've mis-understood the situation), I have the right ascension, declination and phase angle of Venus as decimal angles in cells G80, H80 and M80 and I want the output strings in cells F3, G3 and H3. I still need to search and replace the A1 cell reference in my original post for each of the formulas. As the poster a couple levels above pointed out I could do this as a user defined function in VBA, but I wanted my daft spreadsheet to work on Libre/Open office and on Google sheets with little or no modification. Hence the chain of if statements and round() functions.
- snthpy 4y agoIn the old Excel with only cell grid references I would agree. However in "new Excel" with LET expressions and LAMBDA it is now possible to write legible and self-documenting code where the lack of decent editing support is becoming a problem.
- grvdrm 4y agoWish I could +1 this 100x. Break into small clean chunks that are easy to follow.
- deleted 4y ago[deleted]
- lttlrck 4y agoRelated: https://www.microsoft.com/en-us/garage/blog/2022/03/a-new-way-to-author-and-share-excel-named-formulas-advanced-formula-environment-a-microsoft-garage-project/ https://www.microsoft.com/en-us/garage/blog/2022/03/a-new-wa...
- greggsy 4y agoWow that’s actually kind of cool.
- andylynch 4y agoIt’s really new but the Advanced Formula Editor[1] tackles this, and goes further. It’s a collaboration between the Excel team and MS’ Cambridge boffins. [1] https://www.microsoft.com/en-us/garage/blog/2022/03/a-new-way-to-author-and-share-excel-named-formulas-advanced-formula-environment-a-microsoft-garage-project/ https://www.microsoft.com/en-us/garage/blog/2022/03/a-new-wa...
- masklinn 4y ago> Surely Excel formulas are the most commonly across the whole population of computer users? Maybe, but of developers who’ve installed an editor? And would go through copying formulas back and forth? Surely at that point you’re using vba, or you’ve moved to scripting excel from the outside, or off of excel entirely?
- onychomys 4y agoSome of us have jobs where we write code 50% of the time and the other 50% is yelling at the biologists that work in our labs to please for the love of god stop doing so much stuff with excel formulas.