Aligning text in a cell with respect to character width and spacing

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a column of data with strings xxx | yyyyyyy [zzz]

Where xxx is a unique 3 or 4 digit code, yyyyyyy is a string (of variable length) and zzz is a 3 digit (non unique) code
| and [] are effectively separator characters.

Current look:

AIH | Airpower Corporate [AUT]
AIHT | Airpower Corporate - Operational [BEL]
AIR | Anchor Butter Airpower NV Air [BAB]

How can I change the cell format (or other method that doesn't require manual editing) so all the | are aligned vertically down the column?

TIA,
Jack
 
Last edited:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Formula for said column:
Code:
=[@[Operation_Unit_Code]]&" | "&[@[Operation_Unit_Name]]&" [" &[@[Country_Code_(3CHR)]]&"]"

Adjusted to, which slightly improves, but same issue remains:
Code:
=[@[Operation_Unit_Code]]&REPT(" ",4-LEN([@[Operation_Unit_Code]]))&" | "&[@[Operation_Unit_Name]]&" [" &[@[Country_Code_(3CHR)]]&"]"
 
Last edited:
Upvote 0
In another column : =IF(FIND("|",A1)=4," " & A1, A1)
Format the column with a monotype font and align left.

Or maybe you prefer :
=IF(FIND("|",A1)=4,LEFT(A1,3) & " " & RIGHT(A1),LEN(A1)-3),A1)
 
Last edited:
Upvote 0
I strongly recommend brining the data to First Normal Form, by running Ribbon->Data->Data tools->Text to Columns and choose "|" and "[" a s spearators, later eliminate "]" by Ctrl-H (search and replace).

First NF is always advisable, saves a lot of headache in designing formulas. Besides that, normal cell formating tools may be used to align everything.

J.Ty.
 
Upvote 0
NOTE : If there is a space before | , the formula should be : =IF(FIND("|",A1)=5," " & A1, A1)
And similarly for the other formula.
 
Upvote 0
@footoo ty, about to try it. Sorry for dumb question, I'm using calibri font, is that monotype?

@J.Ty. it's already in FNF, they are 3 separate columns in a table, I need to join together and show unique values in a drop-down list.
Unfortunately. normal cell formatting tools doesn't equalise spacing between non-space characters due to varying character widths as displayed.
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,856
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top