- Katılım
- 15 Mart 2005
- Mesajlar
- 42,719
- Excel Vers. ve Dili
- Microsoft 365 Tr-En 64 Bit
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Option Explicit
Sub Bloklari_Ara_Uyanlari_Listele()
Dim Zaman As Double, Blok_Listesi As Object, Blok_Sayilari As Object, X As Long, Bloklar As Range
Dim Y As Long, Blok_Say As Long, Son As Long, Veri As Variant, Sayi As Variant, Say As Long
Zaman = Timer
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With
Set Blok_Listesi = CreateObject("Scripting.Dictionary")
Set Blok_Sayilari = CreateObject("System.Collections.ArrayList")
Range("H3:L" & Rows.Count).ClearContents
Son = Cells(Rows.Count, 2).End(3).Row
If Son < 4 Then Son = 4
Veri = Range("A3:B" & Son).Value
For X = LBound(Veri, 1) To UBound(Veri, 1)
ReDim Blok_Yer_Listesi(1 To 1)
Say = 0
If Veri(X, 2) <> "" Then
Say = Say + 1
ReDim Preserve Blok_Yer_Listesi(1 To Say)
Blok_Yer_Listesi(Say) = WorksheetFunction.Trim(Veri(X, 2))
For Y = X + 1 To UBound(Veri, 1)
If Veri(Y, 2) <> "" Then
If Veri(X, 1) = Veri(Y, 1) Then
Say = Say + 1
ReDim Preserve Blok_Yer_Listesi(1 To Say)
Blok_Yer_Listesi(Say) = WorksheetFunction.Trim(Veri(Y, 2))
Else
If Not Blok_Sayilari.Contains(Say) Then Blok_Sayilari.Add Say
If Not Blok_Listesi.Exists(WorksheetFunction.Trim(UCase(Replace(Replace(Join(Blok_Yer_Listesi, ","), "ı", "I"), "i", "İ")))) Then
Blok_Say = Blok_Say + 1
Blok_Listesi.Add WorksheetFunction.Trim(UCase(Replace(Replace(Join(Blok_Yer_Listesi, ","), "ı", "I"), "i", "İ"))), Blok_Say
End If
Set Bloklar = Nothing
X = Y - 1
Exit For
End If
End If
Next
End If
Next
Son = Cells(Rows.Count, "D").End(3).Row
If Son < 4 Then Son = 4
Veri = Range("D3:F" & Son).Value
Blok_Sayilari.Sort
Blok_Sayilari.Reverse
ReDim Yer(1 To 1)
ReDim Liste(1 To UBound(Veri, 1), 1 To 5)
Say = 0
For X = LBound(Veri, 1) To UBound(Veri, 1)
For Each Sayi In Blok_Sayilari
For Y = 1 To Sayi
If (X + Y - 1) > UBound(Veri, 1) Then Exit For
ReDim Preserve Yer(1 To Y)
Yer(Y) = WorksheetFunction.Trim(Veri(X + Y - 1, 2))
Next
If Blok_Listesi.Exists(WorksheetFunction.Trim(UCase(Replace(Replace(Join(Yer, ","), "ı", "I"), "i", "İ")))) Then
For Y = 1 To Sayi
Say = Say + 1
Liste(Say, 1) = Veri(X + Y - 1, 1)
Liste(Say, 2) = WorksheetFunction.Trim(Veri(X + Y - 1, 2))
Liste(Say, 3) = Veri(X + Y - 1, 3)
Liste(Say, 4) = Blok_Listesi.Item(WorksheetFunction.Trim(UCase(Replace(Replace(Join(Yer, ","), "ı", "I"), "i", "İ"))))
Liste(Say, 5) = X + Y + 1
Next
End If
Next
Next
If Say > 0 Then
Range("H3").Resize(Say, 5) = Liste
Range("J3").Resize(Say).NumberFormat = "hh:mm:ss"
Columns.AutoFit
With Application
.ScreenUpdating = False
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
MsgBox "İşleminiz tamamlanmıştır." & vbCr & vbCr & _
"İşlem süresi ; " & Format(Timer - Zaman, "0.00") & " Saniye"
Else
With Application
.ScreenUpdating = False
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
MsgBox "Uygun kayıt bulunamadı!", vbExclamation
End If
Set Blok_Listesi = Nothing
Set Blok_Sayilari = Nothing
End Sub