TUNCA ERSİN
Altın Üye
- Katılım
- 18 Ağustos 2021
- Mesajlar
- 131
- Excel Vers. ve Dili
- Office Professional plus 2016 Tr
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Option Explicit
Sub Conditional_Unique_List()
Dim S1 As Worksheet, My_Connection As Object, My_Recordset As Object, My_Query As String
Application.ScreenUpdating = False
Set My_Connection = CreateObject("AdoDB.Connection")
Set My_Recordset = CreateObject("AdoDB.Recordset")
Set S1 = Sheets("Sayfa1")
My_Connection.Open "Provider=Microsoft.Ace.OleDb.12.0;Data Source=" & _
ThisWorkbook.FullName & ";Extended Properties=""Excel 12.0;Hdr=Yes"""
My_Query = "Select Distinct [Liste] From [Veri$] " & _
"Where [Tarih] Between " & CLng(CDate(S1.Range("J1"))) & " And " & CLng(CDate(S1.Range("J1")))
My_Recordset.Open My_Query, My_Connection, 1, 1
S1.Range("A2:A" & S1.Rows.Count).ClearContents
S1.Range("A2").CopyFromRecordset My_Recordset
My_Recordset.Close
My_Query = "Select Distinct [Alıcı] From [Veri$] " & _
"Where [Tarih] Between " & CLng(CDate(S1.Range("J1"))) & " And " & CLng(CDate(S1.Range("J1"))) & " And [Liste] = '" & S1.Range("K1") & "'"
My_Recordset.Open My_Query, My_Connection, 1, 1
S1.Range("K2:K" & S1.Rows.Count).ClearContents
S1.Range("K2").CopyFromRecordset My_Recordset
Columns.AutoFit
My_Recordset.Close
My_Connection.Close
Set My_Recordset = Nothing
Set My_Connection = Nothing
Set S1 = Nothing
Application.ScreenUpdating = True
MsgBox "İşleminiz tamamlanmıştır.", vbInformation
End Sub