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

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

قام بنشر

 السلام عليكم

اريد البحث  في  العمود  c   بتحقق  شرطين   وكذلك البحث في العمود  d   بحسب  التاريخ
لدي  هذا  الكود   لكن  لايعمل  لشرطين 
 

Sub erad()
Dim ib As Boolean
Dim tst As Integer, tst1 As Integer, tst2 As Integer
Dim LastRow As Long, i As Long, ii As Long
Dim SText As String
Dim SText1 As String
Dim StDate As Double, EndDate As Double
With Sheets("واردات")
        .Range("A4:f1500").ClearContents
        SText = .Range("F1")
        SText1 = .Range("E1")
      
        If IsDate(.Range("C1")) And IsDate(.Range("C2")) Then
                StDate = .Range("C1")
                EndDate = .Range("C2")
        Else: ib = True
        End If
End With
ii = 4
With Sheets("data")
        LastRow = .Cells(Rows.Count, 4).End(xlUp).Row
        For i = 4 To LastRow
                '===============================
                If Len(Trim(SText)) = 0 Then tst = 1 Else tst = Abs(CStr(.Cells(i, "c")) = SText)
                                If Len(Trim(SText1)) = 0 Then tst1 = 1 Else tst1 = Abs(CStr(.Cells(i, "C")) = SText1)
                              
                If ib Then tst2 = 1 Else tst2 = Abs(.Cells(i, "D").Value2 >= StDate) * Abs(.Cells(i, "D").Value2 <= EndDate)
                '===============================
                If tst * tst1 * tst2 Then
                       Sheets("واردات").Cells(ii, "A").Value = .Cells(i, "B").Value
                       Sheets("واردات").Cells(ii, "B").Value = .Cells(i, "D").Value
                       Sheets("واردات").Cells(ii, "C").Value = .Cells(i, "m").Value
                       Sheets("واردات").Cells(ii, "D").Value = .Cells(i, "H").Value
                                              Sheets("واردات").Cells(ii, "E").Value = .Cells(i, "K").Value
                       Sheets("واردات").Cells(ii, "F").Value = .Cells(i, "L").Value
                                              
                        ii = ii + 1
                End If
        Next
End With
End Sub

 

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.

×
×
  • اضف...

Important Information