Sort scripture references by chapter number

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,366
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Is there any way to get these scripture references to sort correctly by chapter number?

I know it has to do with the number being a 1 comes before a 4, but not sure how to get this corrected. The left is sorted A-Z with the correct on the right.

Scripture References.xlsx
ABC
1Hdr2Hdr2
2Matthew 11:28-30Matthew 4:19
3Matthew 16:24-25Matthew 5:16
4Matthew 18:20Matthew 6:14
5Matthew 22:37Matthew 6:33
6Matthew 25:13Matthew 7:21
7Matthew 28:18-20Matthew 7:7
8Matthew 4:19Matthew 9:13
9Matthew 5:16Matthew 11:28-30
10Matthew 6:14Matthew 16:24-25
11Matthew 6:33Matthew 18:20
12Matthew 7:21Matthew 22:37
13Matthew 7:7Matthew 25:13
14Matthew 9:13Matthew 28:18-20
Sheet2
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You need to extract the chapter number into a helper column a way that Excel understands as a number, as opposed to as text.

In cell B2, enter the following formula:
Excel Formula:
=INT(TEXTAFTER(TEXTBEFORE(A2,":")," "))
Drag it down to the end of the list of verses, and sort on the new column.

If your actual full list isn't confined to verses from Matthew, and could also have verses from books which themselves have a space in them ("Song of Songs", "1 Corinthians", etc.), then you can use this formula instead:
Excel Formula:
=INT(TEXTBEFORE(INDEX(TEXTSPLIT(A2," "), COLUMNS(TEXTSPLIT(A2," "))), ":"))
 
Upvote 0
Thank you, this works great, but if my list does go to other books outside of Matthew, how do I know sort? In other words, if I now have a number on column be, that will not sort with the book will it?
 
Upvote 0
Try this @FryGirl

this formula will Sort by Name, by Chapter, by Verse

Excel Formula:
=LET(
array,B2:B14,
satu,NUMBERVALUE(TEXTAFTER(TEXTSPLIT(B2:B14,":")," ")),
dua,NUMBERVALUE(TEXTSPLIT(TEXTAFTER(B2:B14,":"),"-")),
tiga,LEFT(B2:B14,1),
SORTBY(array,tiga,1,satu,1,dua,1))



1705027306566.png
 
Upvote 0
Thank you, this works great, but if my list does go to other books outside of Matthew, how do I know sort? In other words, if I now have a number on column be, that will not sort with the book will it?

Ah - you want to be able to sort on (1) Book, then (2) Chapter. And I'm guessing maybe (3) Verse after that? I think you might want to split out each of those pieces of information (Book, Chapter, Verse) in its own column, to give you full control over how the sort works.

In B1 name the column "Book", then in B2 and down:
Excel Formula:
=TEXTBEFORE($A2," ",-1)

In C1 name the column "Chapter", then in C2 and down:
Excel Formula:
=INT(TEXTBEFORE(TEXTAFTER($A2," ",-1), ":"))

And in D1 name the column "First Verse", then in D2 and down:
Excel Formula:
=INT(TEXTBEFORE(TEXTAFTER(TEXTAFTER($A2," ",-1), ":"),"-",,,1))

When you sort the whole table (Data > Sort), just make sure to choose the order like this:
1705029103860.png
 
Upvote 0
On second thought, you could also simplify the formula in D2 to just
Excel Formula:
=INT(TEXTBEFORE(TEXTAFTER($A2, ":"),"-",,,1))
 
Upvote 0
this formula will Sort by Name, by Chapter, by Verse
It will not sort by name unless you use the whole name rather than just the first letter of the name - see two incorrectly sorted values in column E below using your formula structure.
Column F is your formula modified to use the whole name which then does sort those values correctly.

@FryGirl
Column D is a shorter & slightly different approach. In it I have assumed none of the chapter or verse values contain more than 3 digits, though easy to add a couple more "0"s if they can be longer.

24 01 12.xlsm
BCDEF
1Hdr2
2Matthew 11:28-30Luke 5:16Luke 5:16Luke 5:16
3Mark 16:24-25Luke 18:19Luke 18:19Luke 18:19
4Luke 18:20Luke 18:20Luke 18:20Luke 18:20
5Luke 18:19Mark 16:24-25Matthew 4:19Mark 16:24-25
6Matthew 25:13Mark 28:18-20Matthew 6:14Mark 28:18-20
7Mark 28:18-20Matthew 4:19Matthew 6:33Matthew 4:19
8Matthew 4:19Matthew 6:14Matthew 7:7Matthew 6:14
9Luke 5:16Matthew 6:33Matthew 7:21Matthew 6:33
10Matthew 6:14Matthew 7:7Matthew 9:13Matthew 7:7
11Matthew 6:33Matthew 7:21Matthew 11:28-30Matthew 7:21
12Matthew 7:21Matthew 9:13Mark 16:24-25Matthew 9:13
13Matthew 7:7Matthew 11:28-30Matthew 25:13Matthew 11:28-30
14Matthew 9:13Matthew 25:13Mark 28:18-20Matthew 25:13
Sort
Cell Formulas
RangeFormula
D2:D14D2=LET(r,B2:B14,SORTBY(r,TEXTSPLIT(r," ")&TEXT(TEXTSPLIT(TEXTAFTER(r," "),":"),"000")&TEXT(TEXTSPLIT(TEXTAFTER(r,":"),"-"),"000")))
E2:E14E2=LET( array,B2:B14, satu,NUMBERVALUE(TEXTAFTER(TEXTSPLIT(B2:B14,":")," ")), dua,NUMBERVALUE(TEXTSPLIT(TEXTAFTER(B2:B14,":"),"-")), tiga,LEFT(B2:B14,1), SORTBY(array,tiga,1,satu,1,dua,1))
F2:F14F2=LET( array,B2:B14, satu,NUMBERVALUE(TEXTAFTER(TEXTSPLIT(B2:B14,":")," ")), dua,NUMBERVALUE(TEXTSPLIT(TEXTAFTER(B2:B14,":"),"-")), tiga,LEFT(B2:B14,FIND(" ",B2:B14)), SORTBY(array,tiga,1,satu,1,dua,1))
Dynamic array formulas.
 
Upvote 1
Solution
It will not sort by name unless you use the whole name rather than just the first letter of the name - see two incorrectly sorted values in column E below using your formula structure.
Column F is your formula modified to use the whole name which then does sort those values correctly.
Thanks for the correction @Peter_SSs
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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