DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
For a=1 to 8
ListBox2.AddItem Cells(a,1).value
next
Workbooks.Open Filename:="C:\deneme.xls"
For a=1 to 8
ListBox2.AddItem Sheets(1).Cells(a,1).value
next
Workbooks("deneme.xls").Close
Sheets(1) ve deneme.xls sayfa ve çalışma kitabını kendi dosyanıza göre değiştirin...
Merhaba,
dosyalarınızı inceledim. Şimdi, ilk mesajdaki döngüyü; hangi veriyi, nereye almak için istiyorsunuz. Kolay gelsin.
Tekrar merhaba,
konu böyle epeyce uzuyor. Userform1 ve PGiriş formlarında Listbox1 var. Pgiriş formu açılırken, Pkart klasöründeki xls uzantılı dosyaları listeliyor. Şimdi bu aşamada ben ne yapacağımı bilemedim...
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim baglanti As Object, yer As Object, sayfa As Object
Set baglanti = New ADODB.Connection
Set yer = New ADODB.Recordset
ListBox2.Clear
Range("A2:O65536").ClearContents
If ListBox1.Value = "" Then Exit Sub
baglanti.Open "Provider=Microsoft.Ace.Oledb.12.0;Data Source=" & _
ThisWorkbook.Path & "\KartP\" & ListBox1.Value & ";Extended Properties=""Excel 12.0;HDR=no;IMEX=1"";"
yer.Open "Select * From [CariMüsteri$a1:b8] where F1 Is Not Null;", baglanti, adOpenStatic, adLockOptimistic
s = 0
With ListBox2
.Clear
.ColumnCount = 2
.ColumnWidths = "50;82"
Do While Not yer.EOF
.AddItem
.List(s, 0) = yer("F1")
.List(s, 1) = yer("F2") & ""
s = s + 1
yer.MoveNext
Loop
End With
Range("A2").CopyFromRecordset yer
yer.Close
baglanti.Close
Label1.Caption = ""
Label1.Caption = ListBox1.Value
Dim i As Integer
ListView1.ListItems.Clear
c = WorksheetFunction.CountA(ActiveSheet.Range("A:A"))
With ListView1
For i = 1 To c
m = m + 1
.ListItems.Add , , Cells(i + 10, 1)
.ListItems(m).SubItems(1) = Cells(i + 10, 2)
.ListItems(m).SubItems(2) = Cells(i + 10, 3)
.ListItems(m).SubItems(3) = Cells(i + 10, 4)
.ListItems(m).SubItems(4) = Cells(i + 10, 5)
.ListItems(m).SubItems(5) = Cells(i + 10, 6)
.ListItems(m).SubItems(6) = Cells(i + 10, 7)
.ListItems(m).SubItems(7) = Cells(i + 10, 8)
.ListItems(m).SubItems(8) = Cells(i + 10, 9)
.ListItems(m).SubItems(9) = Cells(i + 10, 10)
.ListItems(m).SubItems(10) = Cells(i + 10, 11)
.ListItems(m).SubItems(11) = Cells(i + 10, 12)
.ListItems(m).SubItems(12) = Cells(i + 10, 13)
.ListItems(m).SubItems(13) = Cells(i + 10, 14)
.ListItems(m).SubItems(14) = Cells(i + 10, 15)
Next
End With
ListView1.FullRowSelect = True
ListView1.Gridlines = True
ListView1.FullRowSelect = True
End Sub
Formdaki Listbox1 Dbl Click prosedürünü aşağıdaki kodla değiştirerek deneyiniz. İyi çalışmalar.
Kod:Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Dim baglanti As Object, yer As Object, sayfa As Object Set baglanti = New ADODB.Connection Set yer = New ADODB.Recordset ListBox2.Clear Range("A2:O65536").ClearContents If ListBox1.Value = "" Then Exit Sub baglanti.Open "Provider=Microsoft.Ace.Oledb.12.0;Data Source=" & _ ThisWorkbook.Path & "\KartP\" & ListBox1.Value & ";Extended Properties=""Excel 12.0;HDR=no;IMEX=1"";" yer.Open "Select * From [CariMüsteri$a1:b8] where F1 Is Not Null;", baglanti, adOpenStatic, adLockOptimistic s = 0 With ListBox2 .Clear .ColumnCount = 2 .ColumnWidths = "50;82" Do While Not yer.EOF .AddItem .List(s, 0) = yer("F1") .List(s, 1) = yer("F2") & "" s = s + 1 yer.MoveNext Loop End With Range("A2").CopyFromRecordset yer yer.Close baglanti.Close Label1.Caption = "" Label1.Caption = ListBox1.Value Dim i As Integer ListView1.ListItems.Clear c = WorksheetFunction.CountA(ActiveSheet.Range("A:A")) With ListView1 For i = 1 To c m = m + 1 .ListItems.Add , , Cells(i + 10, 1) .ListItems(m).SubItems(1) = Cells(i + 10, 2) .ListItems(m).SubItems(2) = Cells(i + 10, 3) .ListItems(m).SubItems(3) = Cells(i + 10, 4) .ListItems(m).SubItems(4) = Cells(i + 10, 5) .ListItems(m).SubItems(5) = Cells(i + 10, 6) .ListItems(m).SubItems(6) = Cells(i + 10, 7) .ListItems(m).SubItems(7) = Cells(i + 10, 8) .ListItems(m).SubItems(8) = Cells(i + 10, 9) .ListItems(m).SubItems(9) = Cells(i + 10, 10) .ListItems(m).SubItems(10) = Cells(i + 10, 11) .ListItems(m).SubItems(11) = Cells(i + 10, 12) .ListItems(m).SubItems(12) = Cells(i + 10, 13) .ListItems(m).SubItems(13) = Cells(i + 10, 14) .ListItems(m).SubItems(14) = Cells(i + 10, 15) Next End With ListView1.FullRowSelect = True ListView1.Gridlines = True ListView1.FullRowSelect = True End Sub
yer.Open "Select * From [CariMüsteri$a1:b8] where F1 Is Not Null;", baglanti, adOpenStatic, adLockOptimistic
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim baglanti As Object, yer As Object, sayfa As Object
Set baglanti = New ADODB.Connection
Set yer = New ADODB.Recordset
ListBox2.Clear
Range("A2:O65536").ClearContents
If ListBox1.Value = "" Then Exit Sub
baglanti.Open "Provider=Microsoft.Ace.Oledb.12.0;Data Source=" & _
ThisWorkbook.Path & "\KartP\" & ListBox1.Value & ";Extended Properties=""Excel 12.0;HDR=no;IMEX=1"";"
yer.Open "Select * From [CariMüsteri$] where F1 Is Not Null;", baglanti, adOpenStatic, adLockOptimistic
s = 0
With ListBox2
.Clear
.ColumnCount = 2
.ColumnWidths = "50;82"
Do While Not yer.EOF And s < 6
.AddItem
.List(s, 0) = yer("F1")
.List(s, 1) = yer("F2") & ""
s = s + 1
yer.MoveNext
Loop
End With
yer.MoveFirst
Range("A2").CopyFromRecordset yer
yer.Close
baglanti.Close
Label1.Caption = ""
Label1.Caption = ListBox1.Value
Dim i As Integer
ListView1.ListItems.Clear
c = WorksheetFunction.CountA(ActiveSheet.Range("A9:A" & 65536))
With ListView1
For i = 1 To c
m = m + 1
.ListItems.Add , , Cells(i + 8, 1)
.ListItems(m).SubItems(1) = Cells(i + 8, 2)
.ListItems(m).SubItems(2) = Cells(i + 8, 3)
.ListItems(m).SubItems(3) = Cells(i + 8, 4)
.ListItems(m).SubItems(4) = Cells(i + 8, 5)
.ListItems(m).SubItems(5) = Cells(i + 8, 6)
.ListItems(m).SubItems(6) = Cells(i + 8, 7)
.ListItems(m).SubItems(7) = Cells(i + 8, 8)
.ListItems(m).SubItems(8) = Cells(i + 8, 9)
.ListItems(m).SubItems(9) = Cells(i + 8, 10)
.ListItems(m).SubItems(10) = Cells(i + 8, 11)
.ListItems(m).SubItems(11) = Cells(i + 8, 12)
.ListItems(m).SubItems(12) = Cells(i + 8, 13)
.ListItems(m).SubItems(13) = Cells(i + 8, 14)
.ListItems(m).SubItems(14) = Cells(i + 8, 15)
Next
End With
ListView1.FullRowSelect = True
ListView1.Gridlines = True
ListView1.FullRowSelect = True
End Sub
ListView1.ListItems.Clear
Dim l As Integer
m = 0
With ListView1
Do While Not yer.EOF And m < 6
.ListItems.Add , , yer("F1")
.ListItems(m).SubItems(1) = yer("F2") & ""
m = m + 1
yer.MoveNext
Loop
End With
yer.MoveFirst