اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

الردود الموصى بها

قام بنشر

عند الترتيب لابد من الالتزام  بالشروط بمعتي ان الاصغر سنا مع الاكبر مجموعا مع حرف الهجاء الاول ............ يكون هو الاول بالترتييب 3 شروط فاذا فقد شرط ياتي ثانيا وهكذا لاحظ الصورة .. توضبح اخر كلما توفرت الشروط كلما زاد في الترتيب والعكس صحيحح ..... والملف الثالث هو المطلوب

2025-05-12_100527.jpg

  • تمت الإجابة
قام بنشر

وعليكم السلام ورحمة الله تعالى وبركاته 

جرب هدا

Option Explicit

Sub Tartib()
    Dim WS As Worksheet, lastRow As Long, OnRng As Range
    Dim i As Long, ColSort As String: ColSort = "Z"
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    
    Set WS = ThisWorkbook.Sheets("Sheet1")
    lastRow = WS.Cells(WS.Rows.Count, "B").End(xlUp).Row

    If lastRow < 2 Then GoTo ClearApp

    For i = 2 To lastRow
        WS.Cells(i, ColSort).Value = i
    Next i

    Set OnRng = WS.Range("A2:D" & lastRow).Resize(, WS.Range(ColSort & "2").Column - 1 + 1)
    
    OnRng.Sort Key1:=WS.Range(ColSort & "2"), Order1:=xlAscending, Header:=xlNo
    OnRng.Sort Key1:=WS.Range("C2"), Order1:=xlDescending, _
               Key2:=WS.Range("D2"), Order2:=xlAscending, _
               Key3:=WS.Range("B2"), Order3:=xlAscending, Header:=xlNo
    
    WS.Range(ColSort & "2:" & ColSort & lastRow).ClearContents

ClearApp:
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
End Sub

 

  • Thanks 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information