ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I get Excel to ignore "a", "an", "the" when sorting? (https://www.excelbanter.com/excel-discussion-misc-queries/225893-how-do-i-get-excel-ignore-when-sorting.html)

Sedro6

How do I get Excel to ignore "a", "an", "the" when sorting?
 
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?

Gary''s Student

How do I get Excel to ignore "a", "an", "the" when sorting?
 
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

--
Gary''s Student - gsnu200841


"Sedro6" wrote:

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?



All times are GMT +1. The time now is 01:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com