DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Sub say()
Dim d As String
d = "'C:\Users\Desktop\[SATIŞLAR.xlsx]"
MsgBox Application.ExecuteExcel4Macro("COUNTA(" & d & "Sayfa1'!R5C6:R10000C6)")
End Sub
Ömer üstadın çok çok teşekkür ediyorum. Harika bir kod oldu. Sağlıcakla kalınMerhaba,
Deneyiniz. d değişkenindeki dosya yolunu ve Sayfa1 olarak yazdığım sayfa adını kendinize göre uyarlarsınız.
Kod:Sub say() Dim d As String d = "'C:\Users\Desktop\[SATIŞLAR.xlsx]" MsgBox Application.ExecuteExcel4Macro("COUNTA(" & d & "Sayfa1'!R5C6:R10000C6)") End Sub
Üstad ThisWorkbook.Path modeli uygulanabilir mi ?
d = "'C:\Users\Desktop\[SATIŞLAR.xlsx]" yerine
d = ThisWorkbook.Path & "\[SATIŞLAR.xlsx]"
Option Explicit
Sub Dolu_Satir_Say()
Dim Baglanti As Object, Kayit_Seti As Object, Yol As String, Say As Long
Set Baglanti = CreateObject("AdoDb.Connection")
Set Kayit_Seti = CreateObject("AdoDb.Recordset")
Yol = ThisWorkbook.Path & "\SATIŞLAR.xlsx"
Baglanti.Open "Provider=Microsoft.Ace.OleDb.12.0;Data Source=" & _
Yol & ";Extended Properties=""Excel 12.0;Hdr=No;Imex=1"""
On Error Resume Next
Kayit_Seti.Open "Select F1 From [Sayfa1$F5:F10000] Where Not IsNull(F1)", Baglanti, 1, 1
Say = Kayit_Seti.RecordCount
On Error GoTo 0
MsgBox "Dolu satır sayısı ; " & Say
If Kayit_Seti.State <> 0 Then Kayit_Seti.Close
If Baglanti.State <> 0 Then Baglanti.Close
Set Kayit_Seti = Nothing
Set Baglanti = Nothing
End Sub
Çok teşekkür ediyorum Korhan Ayhan üstadım. Sağlıcakla kalınADO ile alternatif;
C++:Option Explicit Sub Dolu_Satir_Say() Dim Baglanti As Object, Kayit_Seti As Object, Yol As String, Say As Long Set Baglanti = CreateObject("AdoDb.Connection") Set Kayit_Seti = CreateObject("AdoDb.Recordset") Yol = ThisWorkbook.Path & "\SATIŞLAR.xlsx" Baglanti.Open "Provider=Microsoft.Ace.OleDb.12.0;Data Source=" & _ Yol & ";Extended Properties=""Excel 12.0;Hdr=No;Imex=1""" On Error Resume Next Kayit_Seti.Open "Select F1 From [Sayfa1$F5:F10000] Where Not IsNull(F1)", Baglanti, 1, 1 Say = Kayit_Seti.RecordCount On Error GoTo 0 MsgBox "Dolu satır sayısı ; " & Say If Kayit_Seti.State <> 0 Then Kayit_Seti.Close If Baglanti.State <> 0 Then Baglanti.Close Set Kayit_Seti = Nothing Set Baglanti = Nothing End Sub
Üstad ThisWorkbook.Path modeli uygulanabilir mi ?
d = "'C:\Users\Desktop\[SATIŞLAR.xlsx]" yerine
d = ThisWorkbook.Path & "\[SATIŞLAR.xlsx]"
Sub say()
Dim d As String
d = ThisWorkbook.Path & "\[SATIŞLAR.xlsx]"
MsgBox Application.ExecuteExcel4Macro("COUNTA('" & d & "Sayfa1'!R5C6:R10000C6)")
End Sub
Üstad bu şekilde de çok iyi bir alternatif kod oldu. Çok çok sağolun, var olun, sağlıcakla kalınDeneyiniz.
Kod:Sub say() Dim d As String d = ThisWorkbook.Path & "\[SATIŞLAR.xlsx]" MsgBox Application.ExecuteExcel4Macro("COUNTA('" & d & "Sayfa1'!R5C6:R10000C6)") End Sub