04/11/2020, 14:18
feraz
(04/11/2020, 13:56)HORZUM yazdı:Rica ederim.(04/11/2020, 12:52)feraz yazdı: Örnek dosyanızda sütundakiler demiştiniz.İf koşulu ekledim diz olarak.ÇOOKKK TEŞEKKÜR EDERİM....
ilk koduda ayarlarım.Hata olursa koddaki Tr karakterlerini düzeltin.
Sub Aktar()
Dim syfForum As Worksheet, arr(), veri(), say As Long
Dim i As Long, son As Long, sonVer As Long
Set syfForum = ThisWorkbook.Sheets("Form")
say = 0
With ThisWorkbook.Sheets("Veri")
syfForum.Range("A2:F" & Rows.Count).ClearContents
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
veri = .Range("A2:S" & son).Value
ReDim arr(1 To son, 1 To 19)
For i = LBound(veri) To UBound(veri)
If LCase(veri(i, 13)) = "yabancý araç plakasýna" Then
say = say + 1
arr(i, 1) = veri(i, 6)
arr(i, 2) = veri(i, 19) & " " & veri(i, 7)
arr(i, 3) = veri(i, 2) & " " & veri(i, 3)
arr(i, 4) = veri(i, 12)
arr(i, 5) = veri(i, 4)
End If
Next
If say > 0 Then
syfForum.Range("A2").Resize(say, 5).Value = arr
MsgBox "Akrarma Tamam...", vbInformation, "Aktarma"
End If
Application.ScreenUpdating = True
End With
GoTo son2
son:
MsgBox "Akrarma Basarisiz...", vbExclamation, "Aktarma"
son2:
Set syfForum = Nothing: Erase arr: Erase veri
End Sub
Buda ilk kodun düzenlenmiş hali.
Sub Aktar2()
Dim syfForum As Worksheet, say As Long
Dim i As Long, son As Long
Set syfForum = ThisWorkbook.Sheets("Form")
say = 2
syfForum.Range("A2:F" & Rows.Count).ClearContents
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
For i = 2 To son
If LCase(.Cells(i, "M").Value) = "yabancý araç plakasýna" Then
syfForum.Cells(say, 1).Value = .Cells(i, "F").Value
syfForum.Cells(say, 2).Value = .Cells(i, "S").Value & " " & .Cells(i, "G").Value
syfForum.Cells(say, 3).Value = .Cells(i, "B").Value & "-" & .Cells(i, "C").Value
syfForum.Cells(say, 4).Value = .Cells(i, "L").Value
syfForum.Cells(say, 5).Value = .Cells(i, "D").Value
say = say + 1
End If
Next
If say > 2 Then
MsgBox "Akrarma Tamam...", vbInformation, "Aktarma"
Else
MsgBox "Akrarilacak veri bulunamadi...", vbExclamation, "Aktarma"
End If
Application.ScreenUpdating = True
End With
GoTo son2
son:
MsgBox "Akrarma Basarisiz...", vbExclamation, "Aktarma"
son2:
Set syfForum = Nothing
End Sub