How do I get Excel to ignore "a", "an", "the" when sorting?

S

Sedro6

I am maintaining a large list of books. They are customarily sorted by
ignoring the initial "A", "An", or "The" when these are the first words of a
title. Is there a rule or macro that can tell Excel to ignore them in this
position?
 
G

Gary''s Student

Here an implementation:

Sub ignore()
s1 = "A "
s2 = "An "
s3 = "The "
v = Range("A1").Value
If Left(v, 2) = s1 Then
v = Right(v, Len(v) - 2)
Else
If Left(v, 3) = s2 Then
v = Right(v, Len(v) - 3)
Else
If Left(v, 4) = s3 Then
v = Right(v, Len(v) - 4)
End If
End If
End If
MsgBox (v)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top