If I am using the Text to Columns feature on the following data, using ";" as a delimiter:
foo;bar;qux;baz;toast;
quux;jam;beans;
I'll end up with the results "left aligned" in the resulting grid of cells:
|foo |bar |qux |baz |toast |
|quux |jam |beans | | |
However, I want them to be "right aligned":
|foo |bar |qux |baz |toast |
| | |quux |jam |beans |
How can I do this?
NOTE: I know that "right-aligned" might not be the correct term, instead implying
| foo| bar| qux| baz| toast|
| quux| jam| beans| | |
but this isn't what I'm seeking. So, if anyone can suggest a better term for what I'm describing, please do so.
Addendum: As an alternative approach, if anyone knows a way to use Excel to rearrange cells such that
|a |b |c |d | | | | | |
|n |m |o |p |q | | | | |
|e |f |g |h |i |j |k |l | |
|n |m |o |p |q | | | | |
|x | | | | | | | | |
becomes
| | | | | |a |b |c |d |
| | | | |n |m |o |p |q |
| |e |f |g |h |i |j |k |l |
| | | | |n |m |o |p |q |
| | | | | | | | |x |
then that would also work.
The following formulas will allow quick conversion of your data to a form that Text-to-Columns will readily parse right-justified as you describe:
D5
formula (appends a semicolon if absent):
=IF(RIGHT(B5,1)<>";",B5&";",B5)
G5
formula (prepends necessary number of semicolons):
=REPT(";",5-(LEN(D5)-LEN(SUBSTITUTE(D5,";",""))))&D5
Copying the results followed by a Paste-Special-as-Values should afford raw material suitable for a Text-to-Columns conversion.
The solution depends on there being a fixed maximum number of columns; here, five. The formula of G5
could be generalized by adding a 'number of columns to generate' cell elsewhere on the sheet and referencing this new cell instead of the hard-coded 5
value.
Additionally, if you are guaranteed that the data will always have the trailing semicolon, the intermediate step of D5:D7
is superfluous.
EDIT: Per Some_Guy's observation in the comments, the method will also work if all rows are constructed to lack a trailing semicolon.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments