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

تعديل كود تقرير شهرى ليصبح من خلال تاريخ


إذهب إلى أفضل إجابة Solved by سليم حاصبيا,

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

الموضوع اخذ من الوقت اكثر مما يحتاحه

أرجو ان يكون أخر سؤال

الكود لعدم ادراج اصفار

Option Explicit

Sub Trasfer_data_Special()
  Dim R          As Worksheet, Act_sh As Worksheet
  Dim k%, col%, Ro%
  Dim Max_ro%, x%, y%
  Dim Bol        As Boolean
  Dim ST_Dat     As Date
  Dim End_Dat    As Date
  Dim My_sum#
  Dim Mot$
  
Mot = "الاجمالى"

Set R = Sheets("Report_Youmi")
Ro = R.Cells(Rows.Count, 1).End(3).Row
R.Range("C3").CurrentRegion.Resize(Ro - 1).ClearContents
R.Cells(3, 9).Resize(Ro - 2).ClearContents
ST_Dat = Application.Min(R.Range("I2:J2"))
End_Dat = Application.Max(R.Range("I2:J2"))

For k = 3 To Ro - 2

      Bol = Application.Evaluate _
        ("ISREF('" & R.Range("A" & k) & "'!A1)")
    If Bol Then
        Set Act_sh = Sheets(R.Range("A" & k) & "")

        Max_ro = Act_sh.Cells(Rows.Count, 1).End(3).Row
        For y = 3 To 7
            For x = 5 To Max_ro

                If CDate(Act_sh.Cells(x, 1)) >= ST_Dat And _
                   CDate(Act_sh.Cells(x, 1)) <= End_Dat And _
                   Act_sh.Cells(x, 2) <> Mot Then
                   My_sum = My_sum + IIf(IsNumeric(Act_sh.Cells(x, y + 2)), _
                     Act_sh.Cells(x, y + 2), 0)

               End If
               
            Next x
            R.Cells(k, y).Value = My_sum: My_sum = 0
       Next y
    End If
Next k
'+++++++++++++++++++++++++++++++++

R.Cells(Ro - 1, 3).Resize(, 5).Formula = _
"=Sum(C$4:C$" & Ro - 2 & ")"
R.Cells(Ro, 3).Resize(, 5).Formula = _
"=Sum(C$7:C$17)"

R.Cells(4, 9).Resize(Ro - 3).Formula = _
"=IF(COUNTA($C4:$G4)>0,SUM($C4:$G4),"""")"

R.Range("A3:I" & Ro).Value = _
R.Range("A3:I" & Ro).Value
End Sub


 

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

  • أفضل إجابة

تصحيح

Option Explicit

Sub Trasfer_data_Special()
  Dim R          As Worksheet, Act_sh As Worksheet
  Dim k%, col%, Ro%
  Dim Max_ro%, x%, y%
  Dim Bol        As Boolean
  Dim ST_Dat     As Date
  Dim End_Dat    As Date
  Dim My_sum#
  Dim Mot$
  
Mot = "الاجمالى"

Set R = Sheets("Report_Youmi")
Ro = R.Cells(Rows.Count, 1).End(3).Row
R.Range("C3").CurrentRegion.Resize(Ro - 1).ClearContents
R.Cells(3, 9).Resize(Ro - 2).ClearContents
ST_Dat = Application.Min(R.Range("I2:J2"))
End_Dat = Application.Max(R.Range("I2:J2"))

For k = 3 To Ro - 2

      Bol = Application.Evaluate _
        ("ISREF('" & R.Range("A" & k) & "'!A1)")
    If Bol Then
        Set Act_sh = Sheets(R.Range("A" & k) & "")

        Max_ro = Act_sh.Cells(Rows.Count, 1).End(3).Row
        For y = 3 To 7
            For x = 5 To Max_ro

                If CDate(Act_sh.Cells(x, 1)) >= ST_Dat And _
                   CDate(Act_sh.Cells(x, 1)) <= End_Dat And _
                   Act_sh.Cells(x, 2) <> Mot Then
                   My_sum = My_sum + IIf(IsNumeric(Act_sh.Cells(x, y + 2)), _
                     Act_sh.Cells(x, y + 2), 0)

               End If
               
            Next x
           R.Cells(k, y).Value = IIf(My_sum = 0, "", My_sum): My_sum = 0
       Next y
    End If
Next k
'+++++++++++++++++++++++++++++++++

R.Cells(Ro - 1, 3).Resize(, 5).Formula = _
"=if(COUNT(C$4:C$39)>0,SUM(C$4:C$39),"""")"
R.Cells(Ro, 3).Resize(, 5).Formula = _
"=IF(COUNT(C$7:C$17)>0,SUM(C$7:C$17),"""")"

R.Cells(4, 9).Resize(Ro - 3).Formula = _
"=IF(COUNT($C4:$G4)>0,SUM($C4:$G4),"""")"

R.Range("A3:I" & Ro).Value = _
R.Range("A3:I" & Ro).Value
End Sub

 

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

اكثر الله خيرك استاذنا حبيبى

لن اثقل على حضرتك هاحول اعملها بالفورمات سيلس

الكود هو هو ويعمل تمام التمام التمام التمام انا فرحان جدااااااااااااااااااااا بيه ,وادعى لحضرتك من كل قلبى اسعدك الله مثل ما تسعدنا يارب

 

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

الآن فهمت عليك ماذا تريد (كي لا تظهر الاصفار في اي خلية )  بدون فورمات سيلس

استبدل هذا السطر في الكود

 R.Cells(k, y).Value =  My_sum: My_sum = 0

الى

 R.Cells(k, y).Value = IIf(My_sum = 0, "", My_sum): My_sum = 0

 

  • Like 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