Convert numbers to text to be combined in a From-To report heading

johs

New Member
Joined
Feb 4, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I have a PQ table that contains two columns, "From" and "To," which have numerical values from 0 to 10 000 000. I would like the user to define intervals in an Excel sheet that should be used to group numbers in another table.

The input intervals could look like:

From: To:
0 100 000
100 001 1 000 000
1 000 001 5 000 000
5 000 001 10 000 000

I have no problems grouping the records correctly (I do that by comparing the numbers to be grouped with if statements and the "To" numbers and I put the "From" and "To" numbers in two columns that should be easy to combine in one column with "-" as a separator. But would like to output the result to Excel with a heading showing the intervals as above but where the separator "-" is always centered irrespective of the intervals the user is choosing. I would also like to format the numbers with a thousand separator.

I have tried to convert the numbers to text using the Text.Padstart function, but somehow 0 with 9 leading zeros is not the same length as 100 001 with 3 leading zeros. Not a big issue really, I just feel my output report look unprofessional with the "-" zigsagging in the output column. I would really like them to look like this:

0-100 000
100 001-1 000 000
1 000 001-5 000 000
5 000 001-10 000 000

Thank you for your time and assistance.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Maybe you posted with leading spaces or something? Based on the above I don't see how anything is centered as you describe. If that didn't come out right, I suggest you try reposting but put what you want within one of the code tag options from the posting toolbar. I take it that this is not the sort of centering you're after?
1675527019928.png
 
Upvote 0
Apologies and thank you for pointing out that yes I used leading spaces when writing the 2nd table, I didn't realize that leading spaces would be trimmed on posting. The centering i'm after is supposed to be in a vertical column and with the "-" centered -or in the same position- in all rows.
 
Upvote 0
You're welcome & thanks for the recognition!
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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