+ Reply to Thread
Results 1 to 13 of 13

Filter "chapter numbers"

Hybrid View

  1. #1
    Registered User
    Join Date
    10-21-2015
    Location
    EUR
    MS-Off Ver
    Professional Plus 2010
    Posts
    41

    Filter "chapter numbers"

    Hi,

    I am trying to figure out how I can filter numbers that contains punctuation marks (.).
    Now when i filter the numbers from A-Z 1.11.1 is listed before 1.2.1.
    I would like Excel to display 1.2.1, 1.3.1,..........,1.11.1.

    I have tried with different formatting on the cells (standard, numbers, etc).

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,973

    Re: Filter "chapter numbers"

    This proposed solution uses three helper columns that parse the first, middle and last numbers, respectively, and then uses a custom sort of those numbers:
    =VALUE(LEFT(A1,SEARCH(".",A1)-1))
    =VALUE(MID(A1,SEARCH(".",A1)+1,SEARCH(".",A1,SEARCH(".",A1)+1)-SEARCH(".",A1)-1))
    =VALUE(MID(A1,SEARCH(".",A1,SEARCH(".",A1)+1)+1,99))
    Here is a file with the formulas applied to chapter numbers as described in post #1: Filter Chapter Outline.xlsx
    Once you have enabled editing, select the range A1:D6.
    From the Data tab select sort
    first "Sort by" should already be column B
    Select "Add level" and choose "Then by" column C
    Select "Add level" and choose "Then by" column D
    Press OK
    Let me know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Registered User
    Join Date
    10-21-2015
    Location
    EUR
    MS-Off Ver
    Professional Plus 2010
    Posts
    41

    Re: Filter "chapter numbers"

    Thank you, JeteMc

    I think I need a different solution because I need to filter this column "all the time".
    There has to be a way to make Excel filter this way, without using a formula?

    Would it help me If I change the punctuation (.) to a comma (,) in the numbers?

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,973

    Re: Filter "chapter numbers"

    Quote Originally Posted by Generalist View Post
    Would it help me If I change the punctuation (.) to a comma (,) in the numbers?
    I don't think so, at least it didn't work when I tested it.

  5. #5
    Forum Contributor
    Join Date
    06-02-2015
    Location
    delhi
    MS-Off Ver
    2010
    Posts
    104

    Re: Filter "chapter numbers"

    Hmmm you can try it Put your data like this in two column with same data. In data column replace "." with blank Then select numbers will comes in sorted order if you can apply filter on data column. and see actual data will be comeout in sorted way , if I need to figure what i want in filter I can easily do that with macro too.

    Data Actual data
    121 1.2.1
    131 1.3.1
    1111 1.11.1
    1235 1.235

  6. #6
    Registered User
    Join Date
    10-21-2015
    Location
    EUR
    MS-Off Ver
    Professional Plus 2010
    Posts
    41

    Re: Filter "chapter numbers"

    Mandeep: That does not work: "3.3" becomes "33" and is listed before "3.2.9" that becomes "329".

    Any other ideas? I guess this is a fairly normal way of listing numbers?

  7. #7
    Forum Contributor
    Join Date
    06-02-2015
    Location
    delhi
    MS-Off Ver
    2010
    Posts
    104

    Re: Filter "chapter numbers"

    Can you please elaborate what you want to filter out !! So that we can create a solution for that

  8. #8
    Forum Contributor
    Join Date
    06-02-2015
    Location
    delhi
    MS-Off Ver
    2010
    Posts
    104

    Re: Filter "chapter numbers"

    Sorry to declare as instructed by JEtmc without helper or macro this won't be possible. I noted now you said you don't want a helper or willing to look for correct sorted values in filter only that's not possible in filter Box.

  9. #9
    Registered User
    Join Date
    10-21-2015
    Location
    EUR
    MS-Off Ver
    Professional Plus 2010
    Posts
    41

    Re: Filter "chapter numbers"

    Maybe "filter" is the wrong terminology...
    I want to sort the "numbers" in the column fra 1.1.1.1.... to 999.1.1.1.1.1.. In between I have all sorts of combinations (think headings in ms word 1.1. ,1.2.1 ,etc).
    The problem is that Excel think that 1.11.1 is a lower "number" than 1.2.1 - which it isnt.

    I need excel to display the data in the column like this:
    1.1.1.
    1.2.1
    1.3.1
    1.4.1
    1.5.1
    1.6.1
    1.7.1
    1.8.1
    1.9.1
    1.10.1
    1.11.1
    etc

  10. #10
    Forum Contributor
    Join Date
    06-02-2015
    Location
    delhi
    MS-Off Ver
    2010
    Posts
    104

    Re: Filter "chapter numbers"

    Put values in Column A
    Data
    1.1.1
    1.2.1
    1.3.1
    1.4.1
    1.5.1
    1.6.1
    1.7.1
    1.8.1
    1.9.1
    1.10.1
    1.11.1


    Use this formula in B2 and drag it down, Sort it on B column

    Formula: copy to clipboard
    =IFERROR((LEFT(A2,FIND(".",A2)-1)+0)+(RIGHT(A2,LEN(A2)-FIND(".",A2))/1000),A2) 



  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Filter "chapter numbers"

    You could use a UDF to pad numbers to equal length:

    Row\Col
    A
    B
    C
    1
    Chapter
    Sort
    2
    1.1.1 01.01.01 B2: =PadNum(A2, 2)
    3
    1.2.1 01.02.01
    4
    1.3.1 01.03.01
    5
    1.4.1 01.04.01
    6
    1.5.1 01.05.01
    7
    1.6.1 01.06.01
    8
    1.7.1 01.07.01
    9
    1.8.1 01.08.01
    10
    1.9.1 01.09.01
    11
    1.10.1 01.10.01
    12
    1.11.1 01.11.01


    Function PadNum(sInp As String, Optional ByVal iLen As Long = 1) As String
      ' shg 2003
    
      ' Expands numbers in a string to iLen characters for sorting; e.g.,
      '   PadNum("13A1U3", 2)    = "13A01U03"
      '   PadNum("1.2.3.15", 3)  = "001.002.003.015"
    
      ' Numbers are not shortened below their minimal representation:
      '   PadNum("1.123.2.3", 2) = "01.123.02.03"
    
      ' Returns unpadded values if iLen = 1 or omitted
      '   PadNum("01.123.02.03") = "1.123.2.3"
    
      ' All characters other than digits 0-9 are returned as-is
    
      Dim sFmt          As String
      Dim iChr          As Long
      Dim sNum          As String
      Dim sChr          As String
      Dim bNum          As Boolean
    
      sFmt = String(IIf(iLen < 1, 1, IIf(iLen > 15, 15, iLen)), "0")
    
      For iChr = 1 To Len(sInp) + 1   ' the +1 flushes a trailing number
        sChr = Mid(sInp, iChr, 1)
        If sChr Like "#" Then
          bNum = True
          sNum = sNum & sChr
        Else
          If bNum Then
            bNum = False
            
            If Len(sNum) <= 15 Then
              ' it's coercible to a Double without loss of digits
              PadNum = PadNum & Format(CDbl(sNum), sFmt)
            Else
              ' it isn't; use as-is
              PadNum = PadNum & sNum
            End If
            
            sNum = vbNullString
          End If
          PadNum = PadNum & sChr
        End If
      Next iChr
    End Function
    Entia non sunt multiplicanda sine necessitate

  12. #12
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: Filter "chapter numbers"

    make a custom list
    type in a blank datasheet like this
    1.1
    1.2
    ...
    1.11
    1.12
    etc.

    then go to file-> options -> advance -> edit custom lists
    then import your dataset as a new list. that's it.

  13. #13
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: Filter "chapter numbers"

    Quote Originally Posted by Dineth View Post
    make a custom list
    type in a blank datasheet like this
    1.1
    1.2
    ...
    1.11
    1.12
    etc.

    then go to file-> options -> advance -> edit custom lists
    then import your dataset as a new list. that's it.
    this is very easy and take only seconds. don't hesitate to probe, if you are not clear. when you sort go to custom sort, sort by chapter number (or your column heading name) sort on values, order custom list | and then select 1.1,1.2...list
    Last edited by Dineth; 03-11-2016 at 01:29 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 01-22-2016, 09:21 AM
  2. Replies: 7
    Last Post: 03-17-2014, 01:51 PM
  3. [SOLVED] Count syntax for dividing # of "positive numbers" by "total numbers"
    By synses in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 06-18-2013, 09:06 PM
  4. Replies: 0
    Last Post: 08-30-2012, 04:39 PM
  5. Replies: 2
    Last Post: 08-02-2011, 06:57 AM
  6. Replies: 4
    Last Post: 01-21-2008, 08:22 AM
  7. [SOLVED] "Criteria Range" in the "Data/Filter/Advanced Filter" to select Du
    By TC in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-11-2005, 10:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1