Sub Aktar()
Dim syfForum As Worksheet
Dim i As Long, son As Long, sonVer As Long
Set syfForum = ThisWorkbook.Sheets("Form")
With ThisWorkbook.Sheets("Veri")
son = .Cells(Rows.Count, "M").End(3).Row
If son < 2 Then son = 2
If WorksheetFunction.CountA(.Range("M2:M" & Rows.Count)) = 0 Then GoTo son
Application.ScreenUpdating = False
sonVer = syfForum.Range("A" & Rows.Count).End(3)(2, 1).Row
Dim Sql As String
Dim ADO_CN As Object
Dim ADO_RS As Object
Set ADO_CN = CreateObject("Adodb.Connection")
Set ADO_RS = CreateObject("adodb.recordset")
SQL = "SELECT F6, cdate(F19) & ' ' & F7, F2 & '-' & F3, F12, F4 "
SQL = Sql & vbCrLf
SQL = Sql & "FROM [Veri$" & "] where F13='Yabancı Araç Plakasına' ;"
ADO_CN.ConnectionString = "provider=Microsoft.ACE.OLEDB.12.0;data source=" & ThisWorkbook.FullName & _
";extended properties=""excel 8.0;hdr=no;imex=1"""
ADO_CN.Open
ADO_RS.Open SQL, ADO_CN, 3, 1
'
' Eğer Hiç Kayıt Yoksa
If ADO_RS.RecordCount = 0 Then
ADO_RS.Close
ADO_CN.Close
Set ADO_RS = Nothing
Set ADO_CN = Nothing
MsgBox "Kayıt Bulunamadı.", vbCritical, "Veri Yok"
Exit Sub
End If
ADO_RS.movelast
ADO_RS.movefirst
syfForum.Range("a" & sonVer).CopyFromRecordset ADO_RS
ADO_RS.Close
ADO_CN.Close
Set ADO_RS = Nothing
Set ADO_CN = Nothing
MsgBox "Akrarma Tamam...", vbInformation, "Aktarma"
Application.ScreenUpdating = True
End With
GoTo son2
son:
MsgBox "Akrarma Basarisiz...", vbExclamation, "Aktarma"
son2:
Set syfForum = Nothing
End Sub
sayın @HORZUM alternatif olarak aşağıdaki kodu da dener misiniz?