- Katılım
- 3 Haziran 2017
- Mesajlar
- 797
- Excel Vers. ve Dili
- 2007, 32
- Altın Üyelik Bitiş Tarihi
- 08/06/2018
Arkadaşlar,
Kapalı bir çalışma kitabındaki sayfanın adını "sayfa1" olarak değiştirmek istiyorum.
Kapalı çalışma kitabında sadece bir sayfanın ve bu sayfanın adının "Sayfa1" den farklı olduğu varsayılacaktır.
Veya;
Kapalı bir dosyadan veri aldığım aşağıdaki kodu sayfa adı ne olursa olsun, veri aktarma işlemini yapacak şekilde revize etmem gerekiyor.
Yardımcı olabilir misiniz?
Teşekkür ederim şimdiden.
Kapalı bir çalışma kitabındaki sayfanın adını "sayfa1" olarak değiştirmek istiyorum.
Kapalı çalışma kitabında sadece bir sayfanın ve bu sayfanın adının "Sayfa1" den farklı olduğu varsayılacaktır.
Veya;
Kapalı bir dosyadan veri aldığım aşağıdaki kodu sayfa adı ne olursa olsun, veri aktarma işlemini yapacak şekilde revize etmem gerekiyor.
Yardımcı olabilir misiniz?
Teşekkür ederim şimdiden.
Kod:
Private Sub CommandButton8_Click()
Sheets("sorubank").Select
Dim conn As Object, rs As Object, sonsat As Long
On Error GoTo hata
ChDir ThisWorkbook.Path
dosya = Application.GetOpenFilename(FileFilter:="," & _
"*.xls;*.xlsx;*.xlsm", _
Title:="Lütfen dosya seçimi yapınız") ' uzantı eklemeleri yapabilirsiniz
If dosya = False Then ' eğer vazgeçe basarsanız
MsgBox "Dosya seçme işleminden vazgeçildi.", vbInformation, " Bilgi"
Exit Sub
Else
Set conn = CreateObject("adodb.connection")
Set rs = CreateObject("Adodb.recordset")
Application.ScreenUpdating = False
conn.Open ("provider=microsoft.ace.oledb.12.0;data source=" & _
dosya & ";extended properties=""excel 12.0;hdr=no""")
rs.Open "select * from [[COLOR="Red"]Sayfa1[/COLOR]$A2:K65000];", conn, 1, 1
If rs.RecordCount >= 0 Then
sonsat = Cells(Rows.Count, "B").End(xlUp).Row
Range("A" & sonsat + 1).CopyFromRecordset rs
End If
rs.Close: conn.Close
Set rs = Nothing: Set conn = Nothing
Application.ScreenUpdating = True
Range("A1:K65000").HorizontalAlignment = xlCenter
Range("A1:K65000").VerticalAlignment = xlCenter
MsgBox "Dışarıan bankaya soru aktarıldı.", vbInformation, " Bilgi"
End If
Exit Sub
hata:
MsgBox "Klasör bulunamadı", vbCritical, " UYARI"
End Sub