- Katılım
- 15 Mart 2005
- Mesajlar
- 42,742
- Excel Vers. ve Dili
- Microsoft 365 Tr-En 64 Bit
Veri alınacak örnek dosyada paylaşır mısınız?
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Buyurun hocam;Veri alınacak örnek dosyada paylaşır mısınız?
Sub veri_al10()
Sheets("veri").Cells.ClearContents
Range(Cells(3, 1), Cells(Rows.Count, Columns.Count)).ClearContents
Rows("3:" & Rows.Count).Interior.ColorIndex = xlNone
Liste10 (ThisWorkbook.Path)
MsgBox "işlem tamam"
End Sub
Private Sub Liste10(Yol As String)
Dim fL As Object, f As Object
Set fL = CreateObject("Scripting.FileSystemObject")
aranan_Uzanti = fL.GetExtensionName(Application.AddIns.Item(1).FullName)
For Each dosya In fL.GetFolder(Yol).Files
If ThisWorkbook.Name = dosya.Name Then
GoTo atla1
End If
If "~$" = Mid(dosya.Name, 1, 2) Then
GoTo atla1
End If
uzanti = fL.GetExtensionName(dosya.Name)
If aranan_Uzanti = "xlam" Then
If uzanti = "xls" Or uzanti = "xlsm" Or uzanti = "xlsx" Or uzanti = "xlsb" Then
Else
GoTo atla1
End If
End If
If aranan_Uzanti = "xla" Then
If uzanti <> "xls" Then
GoTo atla1
Else
End If
End If
Dim Kayit As ADODB.Recordset
Set Kayit = New ADODB.Recordset
Dosya_adi = fL.GetBaseName(dosya)
uzanti = fL.GetExtensionName(dosya)
Sayfa_adı = "ANA SAYFA"
If uzanti = "xls" Then
baglan = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & dosya & ";Extended Properties=""Excel 8.0;HDR=yes""" 'ofis 2003
Kayit.Open "SELECT * FROM [" & Sayfa_adı & "$] ", baglan, adOpenKeyset, adLockOptimistic
ElseIf uzanti = "xlsb" Or uzanti = "xlsx" Or uzanti = "xlsm" Then
baglan = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & dosya & ";Extended Properties=""Excel 12.0;HDR=yes""" 'ofis 2007
Kayit.Open "SELECT * FROM [" & Sayfa_adı & "$] ", baglan, adOpenKeyset, adLockOptimistic
Else
End If
'strSQL = "SELECT COUNT(*) from [SourceData$A1:IV6] S"
'strSQL = "SELECT S.FIELD_NAME1,S.FIELD_NAME2,S.FIELD_NAME3 from [SourceData$A1:IV6] S"
If Kayit.RecordCount > 0 Then
Sheets("veri").Range("A1").CopyFromRecordset Kayit
Sheets("veri").Range("O1:O" & Kayit.RecordCount).Value = dosya.Name
bul_Click2
Sheets("veri").Cells.ClearContents
End If
Kayit.Close
Set Kayit = Nothing
atla1:
Next
On Error GoTo sonraki
For Each f In fL.GetFolder(Yol).SubFolders
Liste10 (f.Path)
sonraki:
Next
Set fL = Nothing
End Sub
Sub bul_Click2()
For m = 1 To 14
ad = Cells(2, m)
If ad = "" Then GoTo atla1
Set Sh = Sheets("veri")
yer = xlFormulas
yer1 = xlPart
If WorksheetFunction.CountA(Sh.Cells) > 0 Then
sat = Sh.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Else
Exit Sub
End If
If WorksheetFunction.CountA(Cells) > 0 Then
sonsat = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
End If
If sonsat < 3 Then sonsat = 3
Dim SütunAdı As String
SütunAdı = Split(Sh.Cells(1, Val(m)).Address, "$")(1)
For k = 2 To sat
With Sh.Range(SütunAdı & k & ":" & SütunAdı & k)
'With Sh.Range("A" & k & ":N" & k)
Set d = .Find(What:=ad, After:=.Cells(.Cells.Count), LookIn:=yer, lookat:=yer1, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not d Is Nothing Then
FirstAddress = d.Address
Do
For r = 1 To 15
Cells(sonsat, r) = Sh.Cells(d.Row, r)
Next
Cells(sonsat, 16) = d.Row + 1
Cells(sonsat, d.Column).Interior.Color = 65535
sonsat = sonsat + 1
Set d = .FindNext(d)
Loop While Not d Is Nothing And d.Address <> FirstAddress
End If
End With
Next
atla1:
Next m
Set Sh = Nothing
End Sub
Hocam dosyayı indiremiyorum kod paylaşırsanız yada dosya paylaşımı yaparsanız çok sevinirim2. satıra aranan veriyi girip deneyiniz.
Tüm dosyalarınız aynı klasörde olacak şekilde düzenledim.
Doğrudur hocam aynı klasör içindeler ama yinede bu hatayı verdiDosyalar aynı klasör içinde olmalıdır.
Buyurun hocam https://dosya.co/bji5bdpwo5n6/deneme.rar.htmlPaylaşın bakalım.
Hatada sayısal aramamıştım ama illaki olur tarih te aranabilir sayısal verideSayısal veri arama durumunuz olacak mı?