메인 컨텐츠로 가기

Excel에서 셀 내에서 숫자를 정렬하는 방법은 무엇입니까?

열 목록에서 숫자를 정렬하는 것은 쉽고 일반적이지만 단일 셀 내에서 숫자를 정렬 해 본 적이 있습니까? 하나씩 정렬하는 것 외에는 좋은 방법이 없을 수 있습니다. 여기서는 Excel에서 셀 내에서 숫자를 정렬하는 방법에 대해 설명합니다.

수식을 사용하여 셀 내에서 숫자 정렬

사용자 정의 함수를 사용하여 셀 내에서 숫자 정렬

VBA 코드를 사용하여 셀 내에서 쉼표로 구분 된 숫자 정렬


화살표 블루 오른쪽 거품 수식을 사용하여 셀 내에서 숫자 정렬

워크 시트의 셀 내에서 숫자를 정렬하려면 다음과 같이 긴 수식을 적용 할 수 있습니다.

1. 데이터 옆에 다음 수식을 입력하십시오.이 예에서는 C1 셀에 입력하겠습니다. 스크린 샷을 참조하십시오.

=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-numbers-in-cells-1

2. 그런 다음 Ctrl + Shift + Enter 키를 함께 누른 다음 채우기 핸들을이 수식을 적용 할 범위로 드래그하면 숫자가 작은 것에서 큰 것으로 정렬됩니다. 스크린 샷보기 :

doc-sort-numbers-in-cells-1

배송 시 요청 사항:

1. 숫자의 숫자가 셀에서 15보다 큰 경우이 수식은 올바른 결과를 얻지 못합니다.

2. 숫자를 내림차순으로 정렬하려면 다음 공식을 사용할 수 있습니다. =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. 위의 수식에서 A1은 정렬하려는 숫자가 포함 된 셀을 나타내며 필요에 따라 변경할 수 있습니다.


화살표 블루 오른쪽 거품 사용자 정의 함수를 사용하여 셀 내에서 숫자 정렬

수식에는 몇 가지 제한이 있으므로 다음을 사용할 수 있습니다. 사용자 정의 기능 15 자리보다 긴 셀의 숫자를 정렬합니다.

1. 누르고 ALT + F11 키가 열립니다. Microsoft Visual Basic for Applications 창.

2. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창.

VBA 코드 : 셀 내에서 숫자 정렬

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. 그런 다음이 코드를 저장하고 닫은 다음 워크 시트로 돌아가이 수식을 입력합니다. = sortnumsincell (A1) 데이터 옆에있는 빈 셀에 스크린 샷을 참조하십시오.

doc-sort-numbers-in-cells-1

4. 그런 다음 채우기 핸들을이 수식을 포함 할 셀로 드래그하면 다음 스크린 샷과 같이 셀의 모든 숫자가 오름차순으로 정렬됩니다.

doc-sort-numbers-in-cells-1

주의 사항: 숫자를 내림차순으로 정렬하려면이 수식을 입력하세요. = sortnumsincell (A1,1).


화살표 블루 오른쪽 거품 VBA 코드를 사용하여 셀 내에서 쉼표로 구분 된 숫자 정렬

다음 스크린 샷과 같이 숫자가 쉼표, 세미콜론, 마침표 등과 같은 특정 문자로 구분되면 어떻게 셀에서 정렬 할 수 있습니까? 이제 정렬 할 수있는 VBA 코드를 소개합니다.

doc-sort-numbers-in-cells-1

1. 누르고 ALT + F11 키를 눌러 Microsoft Visual Basic for Applications 창.

2. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창.

VBA 코드 : 정렬 번호는 셀 내에서 쉼표로 구분됩니다.

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. 그런 다음 F5 키를 눌러이 코드를 실행 한 다음 팝업 프롬프트 상자에 숫자가 포함 된 셀을 선택합니다. 스크린 샷을 참조하십시오.

doc-sort-numbers-in-cells-1

4. 그런 다음 OK, 셀의 모든 숫자가 원래 범위에서 오름차순으로 정렬되었습니다.

주의 사항: 위 코드에서 필요에 따라 쉼표 ","를 다른 문자로 변경할 수 있습니다. 그리고이 코드는 오름차순으로 만 데이터를 정렬 할 수 있습니다.


관련 기사 :

Excel에서 하이픈으로 숫자를 정렬하는 방법은 무엇입니까?

Excel에서 가장 빈번한 값을 기준으로 데이터를 정렬하는 방법?

Excel에서 도메인별로 이메일 주소를 정렬하는 방법은 무엇입니까?

Excel에서 빈 셀을 맨 위에 놓기 위해 행을 정렬하는 방법은 무엇입니까?

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
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