Data sort

  • Thread starter Thread starter stevebicks
  • Start date Start date
You mean spaces embedded in values?

I'd use a helper column full of formulas like:

=SUBSTITUTE(SUBSTITUTE(A1," ",""),",","")

(It removes the spaces and the commas.)

Then sort by that column instead of the original.
 
Just another way:

Copy that original column and paste special|values into a helper column.

Select that helper column and
Edit|replace
(spacebar)
with
(leave blank)
Replace all

and once more
, (comma)
with
leave blank
Replace all

And sort on this column.
 
the specific problem i have is an excel sheet which is a songlist, th
list has columns as song title, artist, disc number,track number

i want to sort the list A-Z by song title then artist, but ignoring an
spaces, commas etc.


cheers

Stev
 
lol being a newbie i just worked out how to use edit/replace as yo
suggested, which has worked fine but isn't there an easier way?

thanks again

Stev
 
If you want excel to ignore something it doesn't want to ignore, you have to do
something to the data (or a copy of the data).

Maybe the =substitute() suggestion would be easier to copy down each time you
add a new row.
 
Hi Steve,
Here is a user defined function that will do what you asked for
you will need to install the user defined function (UDF) and
use a helper column.
=AlphaWithDigits(A10)
=personal.xls!AlphaWithDigits(A10)
You asked to remove all spaces.

Function AlphaWithDigits(ByVal s As String) As String
'D.McRitchie, .excel, 2004-02-15 modified string for LIKE
'otherwise is same as a posting
'by Harlan Grove, worksheet.functions, 2003-10-20
Dim i As Long, n As Long
n = Len(s)
For i = 1 To n
If Not Mid(s, i, 1) Like "[0-9 A-Z a-z]" Then Mid(s, i, 1) = " "
Next i
AlphaWithDigits = Application.WorksheetFunction.Substitute(s, " ", "")
End Function

If you decided to retain a representative existing space between words,
you would have to make a few changes.
=AlphaWithDigitsSpaces(A10)
=personal.xls!AlphaWithDigitsSpaces(A10)

Function AlphaWithDigitsSpaces(ByVal s As String) As String
'D.McRitchie, .excel, 2004-02-15 modified string for LIKE
'otherwise is same as a posting
'by Harlan Grove, worksheet.functions, 2003-10-20
Dim i As Long, n As Long
n = Len(s)
For i = 1 To n
If Not Mid(s, i, 1) Like "[ 0-9A-Za-z]" Then Mid(s, i, 1) = "^"
Next i
AlphaWithDigitsSpaces = Application.Trim(Application.WorksheetFunction.Substitute(s, "^", ""))
End Function

I tried to gather Harlan's postings on Regular Expressions plus some
additional information he supplied me into a web page:
Extraction of a Group of Digits and Dashes, posted by Harlan Grove
http://www.mvps.org/dmcritchie/excel/grove_digitsid.htm
code in
http://www.mvps.org/dmcritchie/excel/code/digitsid.txt

To install see my Getting Started with Macros and User Defined Functions
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Back
Top