Doğrudur Yusuf Bey. Asıl dosyada birden fazla makro uygulaması mevcut.O sicil numarası sanıyorum dosyada mevcut diğer makroda belirtilen kişinin o tarihler arasındaki tüm izinlerini listelemek için kullanılıyor.
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Doğrudur Yusuf Bey. Asıl dosyada birden fazla makro uygulaması mevcut.O sicil numarası sanıyorum dosyada mevcut diğer makroda belirtilen kişinin o tarihler arasındaki tüm izinlerini listelemek için kullanılıyor.
Desteğiniz için çok teşekkür ederim Haluk Bey.Yusuf Beyin kodu biraz daha hızlı ama, önerdiğim SQL alternatifinin yarım kalmaması için dosyayı revize ettim.
.
Bununla ilgili bir video hazırlamıştım.
Linkten izleyebilirsiniz.
Sub test()
Dim t1 As Date, t2 As Date
Set s1 = Sheets("Data")
Set s2 = Sheets("Listele")
Set d = CreateObject("scripting.dictionary")
Set d = CreateObject("scripting.dictionary")
a = s1.Range("A2:J" & s1.Cells(Rows.Count, 1).End(3).Row).Value
t1 = s2.[B2]
t2 = s2.[C2]
For i = 1 To UBound(a)
If a(i, 7) >= t1 And a(i, 7) <= t2 Then
krt = a(i, 1)
If d.exists(krt) Then
If a(i, 7) > a(d(krt), 7) Then
d(krt) = i
End If
Else
d(krt) = i
End If
End If
Next i
If d.Count > 0 Then
Application.ScreenUpdating = False
s2.Range("A5:J" & Rows.Count).ClearContents
ReDim b(1 To d.Count, 1 To UBound(a, 2))
For Each v In d.keys
say = say + 1
b(say, 1) = v
For y = 2 To UBound(a, 2)
b(say, y) = a(d(v), y)
Next y
Next v
s2.[G5].Resize(say, 3).NumberFormat = "dd.mm.yyyy"
s2.[E5].Resize(say).NumberFormat = "@"
s2.[A5].Resize(say, UBound(a, 2)) = b
Application.ScreenUpdating = True
MsgBox "İşlem tamam.", vbInformation
Else
MsgBox "Sonuç bulunamadı.", vbCritical
End If
End Sub
Alternatif,
Dizi yöntemi ile yapılan çalışma.
Mükemmel çalışıyor. Elinize sağlık.Alternatif,
Dizi yöntemi ile yapılan çalışma.
Kod:Sub test() Dim t1 As Date, t2 As Date Set s1 = Sheets("Data") Set s2 = Sheets("Listele") Set d = CreateObject("scripting.dictionary") Set d = CreateObject("scripting.dictionary") a = s1.Range("A2:J" & s1.Cells(Rows.Count, 1).End(3).Row).Value t1 = s2.[B2] t2 = s2.[C2] For i = 1 To UBound(a) If a(i, 7) >= t1 And a(i, 7) <= t2 Then krt = a(i, 1) If d.exists(krt) Then If a(i, 7) > a(d(krt), 7) Then d(krt) = i End If Else d(krt) = i End If End If Next i If d.Count > 0 Then Application.ScreenUpdating = False s2.Range("A5:J" & Rows.Count).ClearContents ReDim b(1 To d.Count, 1 To UBound(a, 2)) For Each v In d.keys say = say + 1 b(say, 1) = v For y = 2 To UBound(a, 2) b(say, y) = a(d(v), y) Next y Next v s2.[G5].Resize(say, 3).NumberFormat = "dd.mm.yyyy" s2.[E5].Resize(say).NumberFormat = "@" s2.[A5].Resize(say, UBound(a, 2)) = b Application.ScreenUpdating = True MsgBox "İşlem tamam.", vbInformation Else MsgBox "Sonuç bulunamadı.", vbCritical End If End Sub
"Anında görüntü...." diye buna derim işte .... tebrikler.
.
Mükemmel çalışıyor. Elinize sağlık.
Sayın Ziynettin, bu kodu açıklayabilir misiniz? Nasıl bu kadar hızlı çalışıyor?
Sub Mutabakat_izinleri_listele()
Set d = Sheets("Data"): Set m = Sheets("Mutabakat")
Application.ScreenUpdating = False: Application.Calculation = xlCalculationManual
If d.AutoFilterMode = True Then d.AutoFilterMode = False
dson = d.Cells(Rows.Count, 1).End(3).Row
If m.[F5] <> "" And m.[F6] <> "" And m.[F6] < m.[F5] Then
MsgBox "Başlangıç tarihi, bitiş tarihinden küçük olmalıdır."
Exit Sub
End If
If m.[I3] = "" Then
d.Range("A1:J1").AutoFilter Field:=1
Else
d.Range("A1:J1").AutoFilter Field:=1, Criteria1:=m.[I3]
End If
If m.[F5] = "" Then
d.Range("A1:J1").AutoFilter Field:=7
Else
d.Range("A1:J1").AutoFilter Field:=7, Criteria1:=">=" & CLng(m.[F5])
End If
If m.[F6] = "" Then
d.Range("A1:J1").AutoFilter Field:=8
Else
d.Range("A1:J1").AutoFilter Field:=8, Criteria1:="<=" & CLng(m.[F6])
End If
If d.Cells(Rows.Count, 1).End(3).Row > 1 Then
If m.Cells(Rows.Count, 1).End(3).Row > 20 Then m.Range("A21:K" & m.Cells(Rows.Count, 1).End(3).Row).ClearContents
d.Range("D2:E" & dson).Copy : m.[A21].PasteSpecial Paste:=xlPasteValues
d.Range("G2:J" & dson).Copy : m.[C21].PasteSpecial Paste:=xlPasteValues
mesaj = m.Cells(Rows.Count, 1).End(3).Row - 20 & " adet kayıt listelendi."
Else
mesaj = "Aranan kriterlere uygun veri yok."
End If
If d.AutoFilterMode = True Then d.AutoFilterMode = False
Application.ScreenUpdating = True: Application.Calculation = xlCalculationAutomatic
MsgBox mesaj
End Sub