DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Sub MUKERRER_BARKODLAR()
Dim SD As Object, Veri As Variant, Son As Long, Zaman As Double
Dim X As Long, Y As Long, Say As Long, Kayit As Long
Zaman = Timer
Set SD = CreateObject("Scripting.Dictionary")
Son = Cells(Rows.Count, 1).End(3).Row
Veri = Range("A2:B" & Son)
Range("C:D").ClearContents
ReDim Dizi(1 To 2, 1 To Son)
For X = LBound(Veri) To UBound(Veri)
Say = 0
Kayit = Kayit + 1
Dizi(1, Kayit) = Veri(X, 1)
For Y = LBound(Veri) To UBound(Veri)
If Veri(X, 1) = Veri(Y, 1) Then
If Veri(Y, 2) <> True Then
Say = Say + 1
If Not SD.Exists(Veri(X, 1)) Then
SD.Add Veri(X, 1), Nothing
Dizi(2, Kayit) = Say
Else
Dizi(2, Kayit) = Say
End If
End If
Veri(Y, 2) = True
End If
Next
Next
Range("C2").Resize(Kayit, 2) = Application.Transpose(Dizi)
MsgBox "İşleminiz tamamlanmıştır." & Chr(10) & _
"İşlem süresi ; " & Format(Timer - Zaman, "0.000")
End Sub
Sub Benzersizleri_Bul_Say()
Dim Rky As Range, i As Long
Dim Con As New ADODB.Connection
Dim SD As New Scripting.Dictionary
basla = Timer
For Each Rky In Range("A2", Range("A2").End(4))
If Not SD.Exists(Rky.Value) Then
SD.Add Rky.Value, Rky.Value
Cells(Rky.Row, "AD") = Rky.Value
End If
Next Rky
Columns("AD:AD").NumberFormat = "@": Columns("A:A").NumberFormat = "@"
Con.Open "provider=microsoft.ace.oledb.12.0;data source=" & _
ThisWorkbook.FullName & ";extended properties=""Excel 12.0;hdr=no"""
For i = 2 To Range("AD65536").End(3).Row
Set Rs = Con.Execute("select count(f1) from [Sayfa1$] where f1='" & Cells(i, "AD") & "' group by f1")
Cells(i, 2).CopyFromRecordset Rs
Rs.Close
Next i
Con.Close
Columns("AD:AD").ClearContents
MsgBox "İşleminiz tamamlanmıştır." & Chr(10) & _
"İşlem süresi ; " & Format(Timer - basla, "0.000")
Set SD = Nothing
'______________________________________________________________________________________________________________
Dim Veri As Variant, Son As Long, Zaman As Double
Dim X As Long, Y As Long, Say As Long, Kayit As Long
Zaman = Timer
Son = Cells(Rows.Count, 1).End(3).Row
Veri = Range("A2:B" & Son)
Range("C:D").ClearContents
ReDim Dizi(1 To 2, 1 To Son)
For X = LBound(Veri) To UBound(Veri)
Say = 0
Kayit = Kayit + 1
Dizi(1, Kayit) = Veri(X, 1)
For Y = LBound(Veri) To UBound(Veri)
If Veri(X, 1) = Veri(Y, 1) Then
If Veri(Y, 2) <> True Then
Say = Say + 1
If Not SD.Exists(Veri(X, 1)) Then
SD.Add Veri(X, 1), Nothing
Dizi(2, Kayit) = Say
Else
Dizi(2, Kayit) = Say
End If
End If
Veri(Y, 2) = True
End If
Next
Next
Range("C2").Resize(Kayit, 2) = Application.Transpose(Dizi)
MsgBox "İşleminiz tamamlanmıştır." & Chr(10) & _
"İşlem süresi ; " & Format(Timer - Zaman, "0.000")
i = Empty: Set Rky = Nothing: Set Con = Nothing: Set SD = Nothing
End Sub
Sub Benzersizleri_Bul_Say()
Dim Rky As Range, i As Long
Dim con As ADODB.Connection
Set con = New ADODB.Connection
Dim SD As Scripting.Dictionary
Set SD = New Scripting.Dictionary
basla = Timer
For Each Rky In Range("A2", Range("A2").End(4))
If Not SD.Exists(Rky.Value) Then
SD.Add Rky.Value, Rky.Value
Cells(Rky.Row, "AD") = Rky.Value
End If
Next Rky
Columns("AD:AD").NumberFormat = "@": Columns("A:A").NumberFormat = "@"
con.Open "provider=microsoft.ace.oledb.12.0;data source=" & _
ThisWorkbook.FullName & ";extended properties=""Excel 12.0;hdr=no"""
For i = 2 To Range("AD65536").End(3).Row
Set Rs = con.Execute("select count(f1) from [Sayfa1$] where f1='" & Cells(i, "AD") & "' group by f1")
Cells(i, 2).CopyFromRecordset Rs
Rs.Close
Next i
con.Close
Columns("AD:AD").ClearContents
MsgBox "İşleminiz tamamlanmıştır." & Chr(10) & _
"İşlem süresi ; " & Format(Timer - basla, "0.000")
Set SD = Nothing
'______________________________________________________________________________________________________________
Dim Veri As Variant, Son As Long, Zaman As Double
Dim X As Long, Y As Long, Say As Long, Kayit As Long
Dim SC As Scripting.Dictionary
Set SC = New Scripting.Dictionary
Zaman = Timer
Son = Cells(Rows.Count, 1).End(3).Row
Veri = Range("A2:B" & Son)
Range("C:D").ClearContents
ReDim Dizi(1 To 2, 1 To Son)
For X = LBound(Veri) To UBound(Veri)
Say = 0
Kayit = Kayit + 1
Dizi(1, Kayit) = Veri(X, 1)
For Y = LBound(Veri) To UBound(Veri)
If Veri(X, 1) = Veri(Y, 1) Then
If Veri(Y, 2) <> True Then
Say = Say + 1
If Not SC.Exists(Veri(X, 1)) Then
SC.Add Veri(X, 1), Nothing
Dizi(2, Kayit) = Say
Else
Dizi(2, Kayit) = Say
End If
End If
Veri(Y, 2) = True
End If
Next
Next
Range("C2").Resize(Kayit, 2) = Application.Transpose(Dizi)
MsgBox "İşleminiz tamamlanmıştır." & Chr(10) & _
"İşlem süresi ; " & Format(Timer - Zaman, "0.000")
i = Empty: Set Rky = Nothing: Set con = Nothing: Set SC = Nothing
End Sub
Sub Fast_Vlookup_Ciro1()
Sheets("Data").Select
Application.ScreenUpdating = False
Dim zaman As Double, Dizi As Variant, X, DS As Long
Application.StatusBar = "Destek Ekibi"
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
zaman = Timer
Dizi = Sheets("CİRO_SBU").Range("A1").CurrentRegion.Resize(, 5).Value
With CreateObject("Scripting.Dictionary")
For X = 2 To UBound(Dizi, 1)
.Item(Dizi(X, 1)) = Dizi(X, 5) & "#" & Dizi(X, 3)
Next
DS = Sayfa2.Cells(Rows.Count, "A").End(xlUp).Row
Dizi = Sheets("Data").Range("E1:E" & DS).Resize(, 5).Value
For X = 2 To UBound(Dizi, 1)
If .Exists(Dizi(X, 1)) Then
Dizi(X, 5) = Split(.Item(Dizi(X, 1)), "#")(0)
Dizi(X, 3) = Split(.Item(Dizi(X, 1)), "#")(1)
Else
Dizi(X, 5) = ""
Dizi(X, 3) = ""
End If
Next
Application.StatusBar = X
End With
Sheets("Data").Range("G2:I" & Rows.Count).NumberFormat = "General"
Sheets("Data").Range("e1:e" & DS).Resize(, 5) = Dizi
Application.Calculation = xlCalculationAutomatic
Application.StatusBar = False
MsgBox "Statüden Veri alma tamamlandı.[İÇ]" & Chr(10) & _
"İşlem süresi ; " & Format((Timer - zaman), "0.00" & " sn")
End Sub
Ayrıca performansı artırmak için, Late Binding yöntemi yerine Early Bindind yöntemini kullanmak (Referanslardan Activex Data Objects ve Scripting Runtime seçmek) sonuçta bize birkaç sn. kazandıracaktır.
CDbl(Split(.Item(Dizi(X, 1)), "#")(0))
Murat Bey,
Eklediğiniz dosyayı denedim. Sizin düzenlediğiniz kodun ilk bölümü 3,3 saniyede işlemi tamamlıyor. İkinci bölümü ise 27 saniyede işlemi tamamlıyor.
Daha sonra eklediğiniz dosyadaki A sütunundaki numaraları 10.000 satır için farklı numaralar girerek denedim.
Kodun ilk bölümü kilitlendi. Yaklaşık 1 dakika bekledikten sonra durdurmak zorunda kaldım. İkinci bölüm 14,25 saniyede işlemi tamamladı.
Sub Listele()
Dim Rky As Variant, SCD As Object, dizi As Variant
Set SCD = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
Range("BC:BD").ClearContents
dizi = Range("A2:A" & Range("A65536").End(3).Row)
For Each Rky In dizi
If SCD.Exists(Rky) Then
SCD.Item(Rky) = SCD.Item(Rky) + 1
Else
SCD.Add Rky, 1
End If
Next Rky
Range("BC2").Resize(SCD.Count, 1).Value = _
WorksheetFunction.Transpose(SCD.Keys)
Range("BD2").Resize(SCD.Count, 1).Value = _
WorksheetFunction.Transpose(SCD.Items)
Set SCD = Nothing: Set Rky = Nothing: Erase dizi
[A2].Select
5 Do While ActiveCell.Value = Cells(ActiveCell.Row, "BC")
If ActiveCell.Value = "" Then Exit Sub
10 ActiveCell.Offset(1, 0).Select
GoTo 5
Loop
Cells(ActiveCell.Row, "BC").Resize(, 2).Insert Shift:=xlDown
GoTo 10
Application.ScreenUpdating = True
End Sub
Sub Kopyala()
Columns("BD:BD").Copy Columns("B:B")
End Sub
Option Explicit
Sub BARKOD_SAY()
Dim Tablo As PivotTable, Sutun As PivotField
Dim S1 As Worksheet, S2 As Worksheet
Dim X As Long, Dizi(), Zaman As Double
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Zaman = Timer
Set S1 = ActiveWorkbook.Sheets("Sayfa1")
S1.Select
Range("A1").Select
Range("B:B").ClearContents
Set Tablo = Sayfa1.PivotTableWizard
Set S2 = ActiveSheet
Set Sutun = Tablo.PivotFields("BARKOD")
Sutun.Orientation = xlRowField
Set Sutun = Tablo.PivotFields("BARKOD")
Sutun.Orientation = xlDataField
Sutun.Function = xlCount
S2.Cells.Copy
S2.Cells.PasteSpecial xlPasteValues
Range("A1").Select
Application.CutCopyMode = False
Dizi = S2.Range("A1").CurrentRegion.Resize(, 2).Value
With CreateObject("Scripting.Dictionary")
For X = 1 To UBound(Dizi, 1)
.Item(Dizi(X, 1)) = Dizi(X, 2)
Next
Dizi = S1.Range("A1").CurrentRegion.Resize(, 2).Value
For X = 2 To UBound(Dizi, 1)
If .Exists(Dizi(X, 1)) Then
Dizi(X, 2) = .Item(Dizi(X, 1))
End If
Next
End With
S1.Range("A1").CurrentRegion.Resize(, 2) = Dizi
S1.Range("B1") = "Adet"
Application.DisplayAlerts = False
S2.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
MsgBox "İşleminiz tamamlanmıştır." & Chr(10) & _
"İşlem süresi ; " & Format(Timer - Zaman, "0.000")
End Sub
rs.Open "select Barkod, count(*) as say from [Sayfa1$] group by Barkod", con, 1, 1
Do While Not rs.EOF
con.Execute "update [Sayfa1$] set Adet=" & rs(1).Value & " where Barkod=" & rs(0).Value & ""
rs.MoveNext
Loop
rs.Close
Option Explicit
Sub BARKOD_SAY()
Dim Tablo As PivotTable, Sutun As PivotField
Dim S1 As Worksheet, S2 As Worksheet
Dim X As Long, Dizi(), Zaman As Double
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Zaman = Timer
Set S1 = ActiveWorkbook.Sheets("Sayfa1")
S1.Select
Range("A1").Select
Range("B:B").ClearContents
Set Tablo = Sayfa1.PivotTableWizard
Set S2 = ActiveSheet
Set Sutun = Tablo.PivotFields("BARKOD")
Sutun.Orientation = xlRowField
Sutun.Orientation = xlDataField
Sutun.Function = xlCount
S2.Cells.Copy
S2.Cells.PasteSpecial xlPasteValues
Range("A1").Select
Application.CutCopyMode = False
Dizi = S2.Range("A1").CurrentRegion.Resize(, 2).Value
With CreateObject("Scripting.Dictionary")
For X = 1 To UBound(Dizi, 1)
.Item(Dizi(X, 1)) = Dizi(X, 2)
Next
Dizi = S1.Range("A1").CurrentRegion.Resize(, 2).Value
For X = 2 To UBound(Dizi, 1)
If .Exists(Dizi(X, 1)) Then
Dizi(X, 2) = .Item(Dizi(X, 1))
.Item(Dizi(X, 1)) = Empty
End If
Next
End With
S1.Range("A1").CurrentRegion.Resize(, 2) = Dizi
S1.Range("B1") = "Adet"
Application.DisplayAlerts = False
S2.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
MsgBox "İşleminiz tamamlanmıştır." & Chr(10) & _
"İşlem süresi ; " & Format(Timer - Zaman, "0.000")
End Sub