On another forum someone had the following problem in excel and was trying to devise a solution.
Problem:
Column A is a field of text of max 30 characters. He wanted to split column A into columns B & C as close to the middle as possible, around a space. (i.e. "This is a test!", would be split into "This is " and "a test!", 8 characters and 7 characters long, respectively.)
Also, no 'intermediate cells' can be used in the calculation. Only one cell, one formula.
Given that you can't create variables in excel, and you can't use loops, it becomes an interesting problem to try and condense.
Challenge: Derive a solution that works flawlessly. In fact, I'll make this a bit more difficult - derive a solution that works flawlessly on text of any given length with any number of spaces. You can assume that one space will be present in the text. The code should never return an error to the cell (although inner code can return an error if it's handled.)
I've got a solution that I think is flawless - I've got to test it a bit more. I tell you, it is one UNWIELDY chunk of code! (ack, a test just revealed my code is not flawless. It split a 78 character string into a 43,35 combo, while it could have been split 37, 41. )
Oh yeah, try to keep your code as short as possible too. I don't think any solution will be "short", but try to come up with the shortest method possible.
(obviously no using the Call() function to send the text to a DLL or something ;)
I'll post my code later, either in an upgraded form If I can or in it's current "close but no cigar" form.
Problem:
Column A is a field of text of max 30 characters. He wanted to split column A into columns B & C as close to the middle as possible, around a space. (i.e. "This is a test!", would be split into "This is " and "a test!", 8 characters and 7 characters long, respectively.)
Also, no 'intermediate cells' can be used in the calculation. Only one cell, one formula.
Given that you can't create variables in excel, and you can't use loops, it becomes an interesting problem to try and condense.
Challenge: Derive a solution that works flawlessly. In fact, I'll make this a bit more difficult - derive a solution that works flawlessly on text of any given length with any number of spaces. You can assume that one space will be present in the text. The code should never return an error to the cell (although inner code can return an error if it's handled.)
I've got a solution that I think is flawless - I've got to test it a bit more. I tell you, it is one UNWIELDY chunk of code! (ack, a test just revealed my code is not flawless. It split a 78 character string into a 43,35 combo, while it could have been split 37, 41. )
Oh yeah, try to keep your code as short as possible too. I don't think any solution will be "short", but try to come up with the shortest method possible.
(obviously no using the Call() function to send the text to a DLL or something ;)
I'll post my code later, either in an upgraded form If I can or in it's current "close but no cigar" form.