Skip to main content

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?

Uirlisí Táirgiúlachta Oifige is Fearr

Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

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á!
Comments (13)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hola, se pueden ordenar letras en una sola celda por orden alfabético? Yo uso excel para Mac. Gracias
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
Hello, omer,May be the below code can help you, please try:
<div data-tag="code">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 SubAfter inserting the above code, please apply this formula: =CellSort(A1).And you will get the result you need.
This comment was minimized by the moderator on the site
How to sort A-Z text within a cell in Excel?
This comment was minimized by the moderator on the site
hOLA, MI PROBLEMA ES QUE TENGO EXEL 2019 EN ESPAÑOL COMO SERIA LA FORMULA?
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
need to sort 84-12-74-26-98 any order 12-26-74-84-98 or 98-84-74-26-12 thank you
This comment was minimized by the moderator on the site
If CInt(Arr(xMin)) > CInt(Arr(j)) and it works
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Hi, I was wondering how this UDF, =sortnumsincell(A1,1), can be modified more generally, like =sortnumsincell(A1," "," ",,1) where the first argument, A1, is the target cell, the second argument," ", is a delimiter that could take any character, or a space, or nothing, with third argument, " ", a different or same delimiter, and the fourth argument, 1 or 0, 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.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations