Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim Sh_Name As String
Sh_Name = ComboBox1.Text & "-" & ComboBox2.Text
Sheets.Add
ActiveSheet.Name = Sh_Name
Set ws = Sheets("ÌãíÚ ÇáÕÝæÝ")
Set ws2 = Sheets(Sh_Name)
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
For x = 1 To iRow
iRow2 = ws2.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
If ws.Cells(x, 3).Value = ComboBox2.Value And ws.Cells(x, 4).Value = ComboBox1.Value Then
For e = 0 To 3
ws2.Cells(iRow2, e + 1) = ws.Cells(x, e + 1)
Next
End If
Next
c = Application.Ceiling((Application.CountA(ws2.Range("c1:c65536")) / ComboBox3.Value), 1)
i = 2
Z = 1
For x2 = 1 To (ComboBox3.Value - 1)
ws2.Select
Set srng = ws2.Range("A" & (c * x2 + i)).Resize(1, 4)
srng.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
With Selection
.HorizontalAlignment = xlCenter
.MergeCells = False
.Interior.TintAndShade = -0.149998474074526
End With
Selection.Merge
ActiveCell.FormulaR1C1 = "ÇáÕÝ " & ComboBox1.Text & " - " & "ÇáÞÓã " & ComboBox2.Text & " - " & "ÇáãÌãæÚÉ " & Z
i = i + 1
Z = Z + 1
Next
ws.Range("a2:d2").Copy
ws2.Cells(1, 1).Select
ActiveSheet.Paste
irow3 = ws2.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
ws2.Cells(irow3, 1).Select
Set rng3 = ws2.Range("A" & (irow3)).Resize(1, 4)
rng3.Select
With Selection
.HorizontalAlignment = xlCenter
.MergeCells = False
.Interior.TintAndShade = -0.149998474074526
End With
Selection.Merge
ActiveCell.FormulaR1C1 = "ÇáÕÝ " & ComboBox1.Text & " - " & "ÇáÞÓã " & ComboBox2.Text & " - " & "ÇáãÌãæÚÉ " & Z
Columns("A:D").EntireColumn.AutoFit
ActiveSheet.DisplayRightToLeft = True
Application.CutCopyMode = False
UserForm1.Hide
End Sub
تفضل المرفق
لعله يفي بالمطلوب
توزيع الطلبة -h.rar