الكود بطريقة اخرى مع الشرح لتتمكن من تعديله بما يناسبك
Public Sub CopyData2()
Dim rCrit() As String: ReDim rCrit(1 To 2): Const SrcRow = "EA"
Dim x&, i&, Cnt&, arr&, lr&, lastRow&, Cpt As Long
Dim Search_Row As Long, Star_Row As Long, Col As Range
Dim rngA As Variant, rngB As Variant, OneRng As Range
Dim WS As Worksheet: Set WS = Sheets("cheet4")
Dim srcWS As Worksheet: Set srcWS = Sheets("شيت الدور الثاني صف رابع ")
' تحديد صف البداية
Star_Row = 16:
' عمود الفلترة
Search_Row = 131
'تحديد صف وضع البيانات المرحلة
Cnt = 10
With Application
.ScreenUpdating = False
.Calculation = xlManual
lastRow = WS.Range(SrcRow & WS.Rows.Count).End(xlUp).Row
lr = srcWS.Columns("C:AP").Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
'معايير الفلترة
rCrit(1) = "غ": rCrit(2) = "*" & "دور ثان" & "*"
'الاعمدة المرحلة
rngA = Array(3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, _
28, 40, 52, 64, 76, 88, 100, 112, 116, Search_Row)
'الاعمدة المرحل اليها
rngB = Array(3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, _
15, 18, 21, 24, 27, 30, 33, 36, 39, 42)
'("EA")'التحقق من وجود المعايير على عمود
arr = Application.Sum _
(Application.IfError(Application.Match(rCrit, WS.Columns(Search_Row), 0), 0))
If arr = 0 Then: MsgBox " المرجوا التحقق من صحة المعايير ", _
vbCritical, "انتباه": Exit Sub
'افراغ البيانات السابقة
For x = 0 To UBound(rngB)
Set Col = srcWS.Range(srcWS.Cells(Cnt, rngB(x)), srcWS.Cells(lr, rngB(x)))
Col.ClearContents
Next x
With WS
If .AutoFilterMode Then .AutoFilterMode = False
' تحديد نطاق البيانات
With WS.Range("C15:EA15")
.AutoFilter Search_Row - 2, rCrit, xlFilterValues
' نسخ الاعمدة المرئية
For i = 0 To UBound(rngA)
Set OneRng = WS.Range(WS.Cells(Star_Row, _
rngA(i)), WS.Cells(lastRow, rngA(i))).SpecialCells(xlCellTypeVisible)
OneRng.Copy
'لصق البيانات
srcWS.Cells(Cnt, rngB(i)).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Next i
.AutoFilter
End With
End With
.CutCopyMode = False
.Calculation = xlAutomatic
.ScreenUpdating = True
End With
End Sub
SAAD V3.xlsm