메인 컨텐츠로 가기

Excel에서 날짜를 입력하거나 변경할 때 날짜를 자동 정렬하는 방법은 무엇입니까? 

Excel에서 종류 기능은 필요에 따라 오름차순 또는 내림차순으로 날짜를 정렬하는 데 도움이 될 수 있습니다. 그러나 동적이 아닙니다. 날짜를 정렬 한 다음 새 날짜를 추가하면 다시 정렬해야합니다. 워크 시트에 매번 새 날짜를 입력 할 때 날짜를 자동으로 정렬하는 빠르고 좋은 방법이 있습니까?

날짜를 입력하거나 수식으로 변경하면 날짜 자동 정렬

VBA 코드로 날짜를 입력하거나 변경하면 날짜 자동 정렬


화살표 블루 오른쪽 거품 날짜를 입력하거나 수식으로 변경하면 날짜 자동 정렬

예를 들어, 열 A의 원래 날짜, 다음 공식은 정렬하려는 열을 기반으로 새 도우미 열의 날짜 또는 기타 텍스트 문자열을 자동 정렬하는 데 도움이 될 수 있습니다. 다음과 같이하십시오.

1. 다음 공식을 입력하십시오.

=INDEX($A$2:$A$15,MATCH(ROWS($A$2:A2),COUNTIF($A$2:$A$15,"<="&$A$2:$A$15),0)) 날짜 열 옆의 빈 셀에 C2예를 들어, Ctrl + Shift + Enter 키를 함께 사용하면 숫자 시퀀스를 얻은 다음 채우기 핸들을 사용하려는 셀로 드래그합니다. 스크린 샷을 참조하십시오.

주의 사항: 위 공식에서 : A2 : A15 자동 정렬하려는 원래 날짜 범위입니다.

날짜 별 문서 자동 정렬 1

2. 그런 다음 클릭하여 숫자 형식을 날짜 형식으로 지정합니다. 짧은 날짜 인사말 일반 드롭 다운 목록 아래 탭, 스크린 샷 참조 :

날짜 별 문서 자동 정렬 2

3. 그런 다음 시퀀스 번호가 날짜 형식으로 변환되고 원래 날짜도 정렬되었습니다. 스크린 샷을 참조하십시오.

날짜 별 문서 자동 정렬 3

4. 이제부터 새 날짜를 입력하거나 A 열의 날짜를 변경하면 C 열의 날짜가 자동으로 오름차순으로 정렬됩니다. 스크린 샷을 참조하십시오.

날짜 별 문서 자동 정렬 4


화살표 블루 오른쪽 거품 VBA 코드로 날짜를 입력하거나 변경하면 날짜 자동 정렬

다음 VBA 코드를 사용하면 새 날짜를 입력하거나 필요에 따라 날짜를 변경할 때 원래 열의 날짜를 자동으로 정렬 할 수 있습니다.

1. 날짜를 입력하거나 변경할 때 날짜를 자동 정렬하려는 워크 시트로 이동합니다.

2. 시트 탭을 마우스 오른쪽 버튼으로 클릭하고 코드보기 컨텍스트 메뉴에서 튀어 나온 응용 프로그램 용 Microsoft Visual Basic 창에서 다음 코드를 복사하여 빈 칸에 붙여 넣으십시오. 모듈 창, 스크린 샷 참조 :

VBA 코드 : 날짜 입력 또는 변경시 자동 정렬 :

Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice
    On Error Resume Next
    If Application.Intersect(Target, Application.Columns(1)) Is Nothing Then Exit Sub
    If Target.Count > 1 Then Exit Sub
    Range("A1").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _
                                        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

날짜 별 문서 자동 정렬 6

주의 사항: 위 코드에서 입력 한 날짜는 A 열에 자동 정렬되며 변경할 수 있습니다. A1A2 필요에 따라 자신의 세포에.

3. 이제부터 A 열에 날짜를 입력하면 날짜가 자동으로 오름차순으로 정렬됩니다.

최고의 사무 생산성 도구

🤖 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 (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello,This is a great tool. thank you. How can i apply this to multiple columns in the same tab? Could i apply it to restart sorting by date in a new cell of the same column? Would i just repaste the VBA code into the same window?
Thank you.
This comment was minimized by the moderator on the site
Hello Noname9,How are you? To achieve your goal by using VBA code is beyond my reach. But I do know how to use formulas to do the trick.Suppose we have two columns of dates, say A2:B7. How to sort these dates into a new column? Please do as follows.
First, we need to combine the two columns of dates into one column. Copy and paste the formula =INDEX($A$2:$B$7,INT((ROWS(D$2:D2)-1)/2)+1,MOD(ROWS(D$2:D2)-1,2)+1) into cell D2. And drag the fill handle down to combine all dates. Please see screenshot 1.
Then, we will sort the combined dates. Copy and paste the formula =INDEX($D$2:$D$13,MATCH(ROWS($D$2:D2),COUNTIF($D$2:$D$13,"<="&$D$2:$D$13),0)) into F2. And drag the fill handle down to sort all dates. Please see screenshot 2.
Hope it will help. Have a nice day.Sincerely,Mandy
This comment was minimized by the moderator on the site
Hello,What if i want to do this to multiple columns or even have anew start point in the same column? Do i just do a break and recopy the VBA code in that same window?
Thank you.
This comment was minimized by the moderator on the site
That VBA code is solid gold! Thank you! :-)
This comment was minimized by the moderator on the site
With the VBA code, I have copy and pasted the above but wish for the dates in column F to be the values by which the data is sorted. I've changed the range values to F2 and F3500 (the size of the spreadsheet where row 1 is titles), but it still sorts by the dates in column A. Can somebody help me please?
This comment was minimized by the moderator on the site
Hello, Ross,
When applying the code to column F, you should change some references to your need as below code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice 20160606
On Error Resume Next
If Application.Intersect(Target, Application.Columns(6)) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub
Range("F1").Sort Key1:=Range("F2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Is there a particular formula to keep the cells following the sorted date? It would be nice to organize by date but keep the entire row of information. Any help would be much appreciated.
This comment was minimized by the moderator on the site
I mad a checkbook register and it works but I want to figure out how to make my entry’s to go into date order. Any help would be appreciated. I’m still learning excel.
This comment was minimized by the moderator on the site
In addition to the duplicate dates, is there also a way to include multiple columns of data when it sorts? I need it to include multiple columns and sort them all together with the expiration dates.
This comment was minimized by the moderator on the site
how can I do this same sorting calculation but from newest date to oldest? Currently it is Oldest to Newest. Flipping the < sign isn't enough and beyond that I don't have a strong enough understanding of what it is doing. Also I think what may be happening is excel automatically works top to bottom causing difficulties.
This comment was minimized by the moderator on the site
Hello, Bo,

To auto sort the date from newest to oldest, you just need to change the <= to >= in the above formula as follows:
=INDEX($A$2:$A$15,MATCH(ROWS($A$2:A2),COUNTIF($A$2:$A$15,">="&$A$2:$A$15),0))
After inserting this formula, please remember to press Ctrl + Shift + Enter keys together to get the correct result.
Please try it.
This comment was minimized by the moderator on the site
What if there is a duplicate date in the list? And I want both numbers to show up.
This comment was minimized by the moderator on the site
Hello, Ryan,

To sort the date with duplicate ones, you should apply the following formula:

=IFERROR(INDEX($A$2:$A$11,MATCH(ROWS($A$2:A2),COUNTIF($A$2:$A$11,"<="&$A$2:$A$11),0)),IF(ROWS($A$2:A2)<ROWS($A$2:$A$11),B3,""))

Please remember to press Shift + Ctrl + Enter keys together.

Hope it can help you, thank you!
This comment was minimized by the moderator on the site
Awesome :) Working fine
This comment was minimized by the moderator on the site
U forgot to mention the formula is array and you need to ctrl+Shift+ enter. Luckily you had a screenshot or your page would be a waste of cyberspace
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations