Note: The other languages of the website are Google-translated. Back to English
Logáil isteach  \/ 
x
or
x
Cláraigh  \/ 
x

or

Conas uimhreacha a shórtáil laistigh de chill in Excel?

Tá sé éasca agus coitianta dúinn uimhreacha a shórtáil i liosta colún, ach an ndearna tú iarracht riamh uimhreacha a shórtáil laistigh de chill amháin? B’fhéidir nach bhfuil aon bhealach maith ann duit seachas iad a shocrú ceann ar cheann, anseo, labhróidh mé faoi conas uimhreacha a shórtáil laistigh de chealla in Excel.

Sórtáil uimhreacha laistigh de chealla le foirmle

Sórtáil uimhreacha laistigh de chealla a bhfuil Feidhm Sainithe ag an Úsáideoir acu

Sórtáil uimhreacha atá scartha le camóga laistigh de chealla le cód VBA


mboilgeog cheart gorm saighead Sórtáil uimhreacha laistigh de chealla le foirmle

Chun uimhreacha a shórtáil laistigh de chealla i mbileog oibre, is féidir leat an fhoirmle fhada seo a leanas a chur i bhfeidhm, déan é seo le do thoil:

1. In aice le do chuid sonraí, cuir isteach an fhoirmle seo a leanas, sa sampla seo, clóscríobhfaidh mé é i gcill C1, féach an scáileán:

=TEXT(SUM(SMALL(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),ROW(INDIRECT("1:"&LEN(A1))))*10^(LEN(A1)-ROW(INDIRECT("1:"&LEN(A1))))),REPT("0",LEN(A1)))

doc-sort-uimhreacha-i-gcealla-1

2. Ansin brúigh Ctrl + Shift + Iontráil eochracha le chéile, ansin tarraing an láimhseáil líonta go dtí an raon a theastaíonn uait an fhoirmle seo a chur i bhfeidhm, agus gheobhaidh tú go bhfuil na huimhreacha curtha in eagar ó bheag go mór. Féach an pictiúr:

doc-sort-uimhreacha-i-gcealla-1

Nótaí:

1. Má tá dhigit na huimhreach níos mó ná 15 sa chill, ní bhfaighidh an fhoirmle seo an toradh ceart.

2. Más mian leat na huimhreacha a shórtáil in ord íslitheach, is féidir leat an fhoirmle seo a úsáid: =TEXT(SUM(LARGE(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),ROW(INDIRECT("1:"&LEN(A1))))*10^(LEN(A1)-ROW(INDIRECT("1:"&LEN(A1))))),REPT("0",LEN(A1))).

3. Sna foirmlí thuas, léiríonn A1 an chill ina bhfuil na huimhreacha is mian leat a shórtáil, is féidir leat í a athrú go do riachtanas.


mboilgeog cheart gorm saighead Sórtáil uimhreacha laistigh de chealla a bhfuil Feidhm Sainithe ag an Úsáideoir acu

Toisc go bhfuil roinnt teorainneacha leis an bhfoirmle, is féidir leat an méid seo a leanas a úsáid Feidhm Sainithe ag an Úsáideoir chun uimhreacha a shórtáil i gcealla níos faide ná 15 dhigit.

1. Coinnigh síos an ALT + F11 eochracha, agus osclaíonn sé an Fuinneog Microsoft Visual Basic for Applications.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Fuinneog an Mhodúil.

Cód VBA: Sórtáil uimhreacha laistigh de chealla

Function SortNumsInCell(pNum As String, Optional pOrder As Boolean) As String
'Update 20140717
Dim xOutput As String
For i = 0 To 9
  For j = 1 To UBound(VBA.Split(pNum, i))
    xOutput = IIf(pOrder, i & xOutput, xOutput & i)
  Next
Next
SortNumsInCell = xOutput
End Function

3. Ansin sábháil agus dún an cód seo, téigh ar ais chuig do bhileog oibre, agus iontráil an fhoirmle seo = sortnumsincell (A1) isteach i gcill bhán in aice le do chuid sonraí, féach an scáileán:

doc-sort-uimhreacha-i-gcealla-1

4. Agus ansin tarraing an láimhseáil líonta chuig na cealla ar mhaith leat an fhoirmle seo a bheith iontu, agus tá na huimhreacha go léir sna cealla curtha in eagar in ord ardaitheach mar a thaispeántar an scáileán a leanas:

doc-sort-uimhreacha-i-gcealla-1

nótaí: Más mian leat na huimhreacha a shórtáil in ord íslitheach, iontráil an fhoirmle seo le do thoil = sortnumsincell (A1,1).


mboilgeog cheart gorm saighead Sórtáil uimhreacha atá scartha le camóga laistigh de chealla le cód VBA

Má tá d’uimhreacha scartha le carachtair áirithe cosúil le camóg, leathchlón, tréimhse agus mar sin de mar a leanas ar an scáileán, conas a d’fhéadfá iad a shórtáil i gcealla? Anois, tugaim isteach cód VBA chun tú a shórtáil.

doc-sort-uimhreacha-i-gcealla-1

1. Coinnigh síos an ALT + F11 eochracha a oscailt Fuinneog Microsoft Visual Basic for Applications.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Fuinneog an Mhodúil.

Cód VBA: Tá camóga scartha le camóga laistigh de chealla

Sub SortNumsInRange()
'Update 20140717
Dim Rng As Range
Dim WorkRng As Range
Dim Arr As Variant
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Set objArrayList = CreateObject("System.Collections.ArrayList")
For Each Rng In WorkRng
    Arr = VBA.Split(Rng.Value, ",")
    For i = 0 To UBound(Arr)
        xMin = i
        For j = i + 1 To UBound(Arr)
            If Arr(xMin) > Arr(j) Then
                xMin = j
            End If
        Next j
        If xMin <> i Then
            temp = Arr(i)
            Arr(i) = Arr(xMin)
            Arr(xMin) = temp
        End If
    Next i
    Rng.Value = VBA.Join(Arr, ",")
Next
End Sub

3. Ansin brúigh F5 eochair chun an cód seo a rith, agus ansin roghnaigh do chealla ina bhfuil na huimhreacha sa bhosca pras popped amach, féach an scáileán:

doc-sort-uimhreacha-i-gcealla-1

4. Agus ansin cliceáil OK, rinneadh na huimhreacha go léir sna cealla a shórtáil go héadrom sa raon bunaidh.

nótaí: Is féidir leat an camóg “,” a athrú go carachtair ar bith eile de réir mar a theastaíonn uait sa chód thuas. Agus ní féidir leis an gcód seo ach sonraí a shórtáil go ardaitheach.


Earraí gaolmhara:

Conas uimhreacha a shórtáil le hailt in Excel?

Conas sonraí a shórtáil de réir an luacha is minice in Excel?

Conas seoladh ríomhphoist a shórtáil de réir fearainn in Excel?

Conas sraitheanna a shórtáil chun na cealla bána a chur ar barr in Excel?


Na hUirlisí Táirgiúlachta Oifige is Fearr

Réitíonn Kutools for Excel an chuid is mó de do chuid Fadhbanna, agus Méadaíonn sé do Tháirgiúlacht 80%

  • Athúsáid: Cuir isteach go tapa foirmlí casta, cairteacha agus aon rud a d'úsáid tú roimhe seo; Cealla a Chriptiú le pasfhocal; Cruthaigh Liosta Ríomhphoist agus seol ríomhphoist ...
  • Barra Foirmle Super (cuir línte iolracha téacs agus foirmle in eagar go héasca); Leagan Amach Léitheoireachta (líon mór cealla a léamh agus a chur in eagar go héasca); Greamaigh go dtí an Raon Scagtha...
  • Cumaisc Cealla / Sraitheanna / Colúin gan Sonraí a chailleadh; Ábhar Cealla Scoilt; Comhcheangail Sraitheanna / Colúin Dúblacha... Cill Dúblach a Chosc; Déan comparáid idir Ranganna...
  • Roghnaigh Dúblach nó Uathúil Sraitheanna; Roghnaigh Blank Rows (tá na cealla uile folamh); Aimsigh Super agus Fuzzy Aimsigh i go leor Leabhar Oibre; Roghnaigh go randamach ...
  • Cóip Díreach Cealla Il gan tagairt fhoirmle a athrú; Tagairtí Cruthaigh Auto chuig Bileoga Il; Cuir Urchair isteach, Boscaí Seiceála agus go leor eile ...
  • Sliocht Téacs, Cuir Téacs leis, Bain de réir Poist, Bain Spás; Subtotals Paging a chruthú agus a phriontáil; Tiontaigh Idir Ábhar Cealla agus Tráchtanna...
  • Scagaire Super (scéimeanna scagaire a shábháil agus a chur i bhfeidhm ar bhileoga eile); Ard-Sórtáil de réir míosa / seachtaine / lae, minicíocht agus níos mó; Scagaire Speisialta le cló trom, iodálach ...
  • Comhcheangail Leabhair Oibre agus Bileoga Oibre; Cumaisc Táblaí bunaithe ar eochaircholúin; Roinn Sonraí i Ilbhileoga; Baisc Tiontaigh xls, xlsx agus PDF...
  • Níos mó ná 300 gné chumhachtach. Tacaíochtaí Office / Excel 2007-2019 agus 365. Tacaíonn sé le gach teanga. Imscaradh éasca i d’fhiontar nó d’eagraíocht. Gnéithe iomlána triail saor in aisce 30 lá. Ráthaíocht ar ais airgid 60 lá.
cluaisín kte 201905

Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
bun officetab
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    omer1905 · 9 months ago
    Hi thanks for nice good for sorting numbers which separated by commas within cells with VBA code

    Just I have faced one problem with the code.

    The code cannot detect three digit number. for example the numbers (65, 93, 53, 72, 64, 85, 103, 48, 77, 81, 54) after applying the code, the new order (103, 48, 53, 54, 64, 65, 72, 77, 81, 85, 93)

    Do you have any solution for the problem?
    • To post as a guest, your comment is unpublished.
      skyyang · 9 months ago
      Hello, omer,
      May be the below code can help you, please try:

      Public Function CellSort(r As Range) As String Dim bry() As Long, L As Long, U As Long ch = r(1).Text ary = Split(ch, ",") L = LBound(ary) U = UBound(ary) ReDim bry(L To U) For i = LBound(ary) To UBound(ary) bry(i) = CLng(ary(i)) Next i Call BubbleSort(bry) For i = LBound(bry) To UBound(bry) ary(i) = CStr(bry(i)) Next i CellSort = Join(ary, ",") End Function Sub BubbleSort(arr) Dim strTemp As Variant Dim i As Long Dim j As Long Dim lngMin As Long Dim lngMax As Long lngMin = LBound(arr) lngMax = UBound(arr) For i = lngMin To lngMax - 1 For j = i + 1 To lngMax If arr(i) > arr(j) Then strTemp = arr(i) arr(i) = arr(j) arr(j) = strTemp End If Next j Next i End Sub
      After inserting the above code, please apply this formula: =CellSort(A1).
      And you will get the result you need.
  • To post as a guest, your comment is unpublished.
    Biplab Das · 1 years ago
    How to sort A-Z text within a cell in Excel?
  • To post as a guest, your comment is unpublished.
    WALLAS · 1 years ago
    hOLA, MI PROBLEMA ES QUE TENGO EXEL 2019 EN ESPAÑOL COMO SERIA LA FORMULA?
  • To post as a guest, your comment is unpublished.
    MF · 3 years ago
    Hi, the VBA code seems to output incorrectly, example before 13,50,47,7,39 and after 13-39-47-50-7. Any ideas why?
  • To post as a guest, your comment is unpublished.
    Jijoy P Jacob · 3 years ago
    i want to sort total an amount 14000 to 20000 from various row Example:- 2000,1500 one row and like that all row amount to arrange
  • To post as a guest, your comment is unpublished.
    orly · 4 years ago
    need to sort 84-12-74-26-98 any order 12-26-74-84-98 or 98-84-74-26-12
    thank you
    • To post as a guest, your comment is unpublished.
      dd · 1 years ago
      If CInt(Arr(xMin)) > CInt(Arr(j)) and it works
  • To post as a guest, your comment is unpublished.
    Dave · 4 years ago
    Is there is any way to sort more numbers in same time from one cell? Example, i have a list of 50000 asset numbers such as A1234,A1235... and i need to pull 500 specific numbers and i need to pull 500 at the time to make change and save.Thank you
  • To post as a guest, your comment is unpublished.
    Brian Dolan · 4 years ago
    I have a series of cells with numbers separated by a space that I want to sort.
    eg 8 4 5 1 6 3 that I want to sort as 1 3 4 5 6 8
    Any help appreciated
  • To post as a guest, your comment is unpublished.
    wschloss · 6 years ago
    Hi, I was wondering how this UDF, [b]=sortnumsincell(A1,1)[/b], can be modified more generally, like [b]=sortnumsincell(A1," "," ",,1)[/b] where the first argument, [b]A1[/b], is the target cell, the second argument,[b]" "[/b], is a delimiter that could take any character, or a space, or nothing, with third argument, [b]" "[/b], a different or same delimiter, and the fourth argument, [b]1 or 0[/b], indicating an ascending or descending sort, with the result string displaying, correctly sorted, within one cell, with delimiter default same as the original string unless specified in the third term. I would like it to work both on string and numerical, and sometimes the second or third argument might be a line feed, as would be manually entered with alt-enter.
    You'd be my hero of the month if you could do that. I tried but failed miserably.
    Thank you.
  • To post as a guest, your comment is unpublished.
    noob · 6 years ago
    sir, could you please help to sort the data for the duplicate first whether it's small or big
    Example
    1211 ---> 1112
    9495 ---> 9945
    7379 ---> 7739

    Thanks a lot for your help