انتقل إلى المحتوى الرئيسي

كيفية الفرز التلقائي للتاريخ عند إدخال التاريخ أو تغييره في 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، على سبيل المثال ، ثم اضغط على كترل + شيفت + إنتر معًا ، وستحصل على تسلسل رقمي ، ثم اسحب مقبض التعبئة لأسفل إلى الخلايا التي تريد استخدامها ، انظر لقطة الشاشة:

ملاحظات: في الصيغة أعلاه: A2: A15 هو النطاق الزمني الأصلي الذي تريد ترتيبه تلقائيًا.

فرز تلقائي للمستندات حسب التاريخ 1

2. ثم قم بتنسيق الأرقام بتنسيق التاريخ من خلال النقر التاريخ القصير من العلاجات العامة القائمة المنسدلة تحت الصفحة الرئيسية علامة التبويب ، انظر لقطة الشاشة:

فرز تلقائي للمستندات حسب التاريخ 2

3. ثم تم تحويل أرقام التسلسل إلى تنسيق التاريخ ، وتم فرز التاريخ الأصلي أيضًا ، انظر الصورة:

فرز تلقائي للمستندات حسب التاريخ 3

4. من الآن فصاعدًا ، عند إدخال تاريخ جديد أو تغيير التاريخ في العمود A ، سيتم فرز التاريخ الموجود في العمود C بترتيب تصاعدي تلقائيًا ، انظر الصورة:

فرز تلقائي للمستندات حسب التاريخ 4


السهم الأزرق الحق فقاعة تاريخ الفرز التلقائي عندما يتم إدخال التاريخ أو تغييره باستخدام رمز VBA

يمكن أن تساعدك التعليمات البرمجية لـ VBA التالية على فرز التاريخ تلقائيًا في العمود الأصلي عند إدخال تاريخ جديد أو تغيير التاريخ كما تريد.

1. انتقل إلى ورقة العمل التي تريد فرز التاريخ تلقائيًا عند إدخال تاريخ أو تغييره.

2. انقر بزر الماوس الأيمن فوق علامة تبويب الورقة ، وحدد عرض الرمز من قائمة السياق ، في النافذة المنبثقة ميكروسوفت فيسوال باسيك للتطبيقات نافذة ، يرجى نسخ ولصق الكود التالي في الفراغ وحدة نافذة ، انظر لقطة الشاشة:

كود فبا: الفرز التلقائي عند إدخال التاريخ أو تغييره:

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 ، يمكنك تغييره A1 و A2 إلى الخلايا الخاصة بك كما تحتاج.

3. من الآن فصاعدًا ، عند إدخال التاريخ في العمود "أ" ، سيتم فرز التاريخ تصاعديًا تلقائيًا.

أفضل أدوات إنتاجية المكتب

🤖 مساعد Kutools AI: إحداث ثورة في تحليل البيانات على أساس: التنفيذ الذكي   |  إنشاء التعليمات البرمجية  |  إنشاء صيغ مخصصة  |  تحليل البيانات وإنشاء الرسوم البيانية  |  استدعاء وظائف Kutools...
الميزات الشعبية: البحث عن التكرارات أو تمييزها أو تحديدها   |  حذف الصفوف الفارغة   |  دمج الأعمدة أو الخلايا دون فقدان البيانات   |   جولة بدون صيغة 
سوبر بحث: معايير متعددة VLookup    VLookup ذات القيمة المتعددة  |   VLookup عبر أوراق متعددة   |   بحث غامض ....
قائمة منسدلة متقدمة: إنشاء القائمة المنسدلة بسرعة   |  القائمة المنسدلة التابعة   |  قائمة منسدلة متعددة التحديد ....
مدير العمود: إضافة عدد محدد من الأعمدة  |  نقل الأعمدة  |  تبديل حالة رؤية الأعمدة المخفية  |  مقارنة النطاقات والأعمدة 
الميزات المميزة: التركيز على الشبكة   |  عرض تصميم   |   شريط الفورمولا الكبير    مدير المصنفات والأوراق   |  مكتبة الموارد (النص السيارات)   |  منتقي التاريخ   |  اجمع أوراق العمل   |  تشفير/فك تشفير الخلايا    إرسال رسائل البريد الإلكتروني عن طريق القائمة   |  سوبر تصفية   |   مرشح خاص (تصفية غامق / مائل / يتوسطه خط ...) ...
أفضل 15 مجموعة أدوات12 نص الأدوات (إضافة نص, إزالة الأحرف، ...)   |   +50 رسم الأنواع (مخطط جانت، ...)   |   40+ عملي الصيغ (احسب العمر على أساس تاريخ الميلاد، ...)   |   19 إدخال الأدوات (أدخل رمز الاستجابة السريعة, إدراج صورة من المسار، ...)   |   12 تحويل الأدوات (أرقام إلى كلمات, نتيجة تحويل عملة، ...)   |   7 دمج وتقسيم الأدوات (الجمع بين الصفوف المتقدمة, تقسيم الخلايا، ...)   |   ... و اكثر

عزز مهاراتك في Excel باستخدام Kutools for Excel، واختبر كفاءة لم يسبق لها مثيل. يقدم Kutools for Excel أكثر من 300 ميزة متقدمة لتعزيز الإنتاجية وتوفير الوقت.  انقر هنا للحصول على الميزة التي تحتاجها أكثر...

الوصف


يجلب Office Tab الواجهة المبوبة إلى Office ، ويجعل عملك أسهل بكثير

  • تمكين التحرير والقراءة المبوبة في Word و Excel و PowerPointوالناشر والوصول و Visio والمشروع.
  • فتح وإنشاء مستندات متعددة في علامات تبويب جديدة من نفس النافذة ، بدلاً من النوافذ الجديدة.
  • يزيد من إنتاجيتك بنسبة 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