اذهب الي المحتوي
أوفيسنا

كيف نختار مجموعة عشوائية من التلاميذ


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

ذا اردنا ان تختار مجموعة عشوائية من تلاميذ صف ( بعدد محدد) و ادراج اسمائهم في عامود (دون تكرار)
و في عامود اخر ما بيقى منهم
اكسل يحل لنا هذا الموضوع بواسطة هذا الملف

الكود

Option Explicit
Sub RANDOM_ELEVES()
If ActiveSheet.Name <> "Salim" Then GoTo Exit_Me
ActiveSheet.Unprotect
 With Application
  .ScreenUpdating = False
  .Calculation = xlCalculationManual
 End With
Dim lr%: lr = Cells(Rows.Count, 2).End(3).Row
 Dim x%: x = [h2]
 Dim y%: y = [h3]
 If Not IsNumeric(x) Or x < 1 _
  Or x Mod 1 <> 0 Or x >= y Then
  x = Int(y / 2)
  [h2] = x
  End If
  
Range("d2", Range("d1").End(xlDown)).ClearContents
Range("f2", Range("f1").End(xlDown)).ClearContents
Dim My_Rg: Set My_Rg = Range("b2:b" & lr)
Dim g()
ReDim g(1 To lr)
Dim i
Dim k%: k = 1
Do
Randomize
 i = Int((lr - 1 + 1) * Rnd + 1)
   If g(i) = False Then
   g(i) = i
   k = k + 1
   Cells(k, 4) = My_Rg.Cells(i)
   End If
   Loop Until k = [h2] + 1
   Range("d2:d" & k).SortSpecial Header:=xlNo

k = 2
For i = LBound(g) To UBound(g)

  If g(i) = vbNullString Then
 
    Cells(k, 6) = My_Rg.Cells(i)
    k = k + 1
  End If
    Next
  Erase g
 ActiveSheet.Protect
Exit_Me:
 With Application
  .ScreenUpdating = True
  .Calculation = xlCalculationAutomatic
 End With
End Sub

الملف

ا

Choose_Studiantes.xlsm

  • Like 4
رابط هذا التعليق
شارك

الرجاء ان تجدوا لي حل 
هل هناك دالة تقوم 
مثلا لدينا سلاسل مرقمة من 1 الى 50 وكل سلسلة فيها اوراق من 8 الى 20 ورقة ولدي 31 استاذ يصححون اوراق الامتحانات كيف اوزع الظروف عليهم وتكون ارقام الظروف عشوائية وعدد الاوراق متساوي على الاساتذة

وهل هناك كود vba وشكرا
Gérer
 
 
رابط هذا التعليق
شارك

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