- Katılım
- 28 Haziran 2007
- Mesajlar
- 246
- Excel Vers. ve Dili
- Excel 2003 Tr
arkadaslar gunaydınlar...
bir sayfaya eklenmesi gereken iki kodkod var. bunları birleştirmem lazım. ancak bir turlu beceremedim. bir yerini cozuyorum baska bir yerde patlıyor. rica etsem yardımcı olur musunuz.
Sayın COST_CONTROL'den aldığım mukerrer kayıt için aldığım ve Sayın Ripek'den de veritabanından bilgi çeken kodların her ikiside aşağıdadır.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Intersect(Target, [E4:E65536,G4:G65536,I4:J65536,M4:M65536]) Is Nothing Then Exit Sub
If IsEmpty(Target) Or InStr(1, Target.Address, ":") <> 0 Then Exit Sub
If Cells(Target.Row, "E") <> "" And Cells(Target.Row, "G") <> "" And Cells(Target.Row, "I") <> "" And Cells(Target.Row, "J") <> "" And Cells(Target.Row, "M") <> "" Then
SAY = WorksheetFunction.CountIf(Columns(Target.Column), Target)
If SAY > 1 Then
Set BUL = Columns(Target.Column).Find(Target)
If Not BUL Is Nothing Then
ADRES = BUL.Address
Do
If Cells(Target.Row, "E") = Cells(BUL.Row, "E") And Cells(Target.Row, "G") = Cells(BUL.Row, "G") And Cells(Target.Row, "I") = Cells(BUL.Row, "I") And Cells(Target.Row, "J") = Cells(BUL.Row, "J") And Cells(Target.Row, "M") = Cells(BUL.Row, "M") Then
SATIR = IIf(SATIR = "", BUL.Row & Space(1), SATIR & ", " & BUL.Row & Space(1))
End If
Set BUL = Columns(Target.Column).FindNext(BUL)
Loop While Not BUL Is Nothing And BUL.Address <> ADRES
GoTo UYARI
End If: End If: End If
GoTo SON
UYARI: ONAY = MsgBox("Bu kayıt daha önce aşağıdaki satırlarda girilmiştir !" & Chr(10) & Chr(10) & SATIR & Chr(10) & Chr(10) & "İşleme devam etmek istiyor musunuz?", vbYesNo + vbCritical, "DİKKAT !")
If ONAY = vbNo Then
Range("E" & Target.Row, "O" & Target.Row) = ""
Target.Select
Exit Sub: End If
Target.Offset(1, 0).Select
SON:
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
'On Error Resume Next
If Intersect(Target, [G4:G65536]) Is Nothing Then Exit Sub
If Target.Value = "" Then
Range("E" & Target.Row & ":f" & Target.Row).Select
Selection.ClearContents
Range("H" & Target.Row & ":O" & Target.Row).Select
Selection.ClearContents
Cells(Target.Row, "G").Select
Exit Sub
Else
Baglan:
End If
If Intersect(Target, [G4:G65536]) Is Nothing Then Exit Sub
Dim Baglanti As ADODB.Connection
Dim Kayit1 As ADODB.Recordset
Dim FSO As Object
Dim SQLStr, Kaynak1, Kaynak2, Kaynak3, verginosu As String
'***********************************************************************
CurrentRow = Target.Row
CurrentValue = Target.Value
Kaynak1 = "z:\belgelerim\2007 office muhasebe\program_data\veritabani.xls"
Kaynak2 = "d:\belgelerim\2007 office muhasebe\program_data\veritabani.xls"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(Kaynak1) = True Then
Kaynak3 = Kaynak1
ElseIf FSO.FileExists(Kaynak2) = True Then
Kaynak3 = Kaynak2
Else
MsgBox "Veritabani.xls Dosyası Bulunamadı.", vbInformation, "Bilgi"
Exit Sub
End If
verginosu = CurrentValue
SQLStr = "SELECT MÜKELLEFADISOYADI,VDAİRESİ,VERGİNO,ADRESİ FROM [data$] WHERE VERGİNO=" & verginosu
Set Baglanti = CreateObject("ADODB.Connection")
With Baglanti
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Properties("Data Source").Value = Kaynak3
.CursorLocation = adUseServer
.Mode = adModeReadWrite
.Open
End With
If Err = 0 Then
Set Kayit1 = CreateObject("ADODB.Recordset")
With Kayit1
.ActiveConnection = Baglanti
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Source = SQLStr
.Open
End With
'***********************************************************************
If Kayit1.RecordCount = 1 Then
Cells(CurrentRow, "e").Value = Kayit1("MÜKELLEFADISOYADI")
Cells(CurrentRow, "f").Value = Kayit1("VDAİRESİ")
Cells(CurrentRow, "h").Value = Kayit1("ADRESİ")
Else
MsgBox "Aradığınız Kayıt Bulunamadı.", vbInformation, "Bilgi"
UserForm1.Show
End If
Else
Son:
MsgBox "Bağlantı Hatası.Kontrol Ediniz", vbInformation, "Bilgi"
End If
If CBool(Kayit1.State And adStateOpen) = True Then Kayit1.Close
Set Kayit1 = Nothing
If CBool(Baglanti.State And adStateOpen) = True Then Baglanti.Close
Set Baglanti = Nothing
Set FSO = Nothing
Target.Offset(1, 0).Select
End Sub
bir sayfaya eklenmesi gereken iki kodkod var. bunları birleştirmem lazım. ancak bir turlu beceremedim. bir yerini cozuyorum baska bir yerde patlıyor. rica etsem yardımcı olur musunuz.
Sayın COST_CONTROL'den aldığım mukerrer kayıt için aldığım ve Sayın Ripek'den de veritabanından bilgi çeken kodların her ikiside aşağıdadır.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Intersect(Target, [E4:E65536,G4:G65536,I4:J65536,M4:M65536]) Is Nothing Then Exit Sub
If IsEmpty(Target) Or InStr(1, Target.Address, ":") <> 0 Then Exit Sub
If Cells(Target.Row, "E") <> "" And Cells(Target.Row, "G") <> "" And Cells(Target.Row, "I") <> "" And Cells(Target.Row, "J") <> "" And Cells(Target.Row, "M") <> "" Then
SAY = WorksheetFunction.CountIf(Columns(Target.Column), Target)
If SAY > 1 Then
Set BUL = Columns(Target.Column).Find(Target)
If Not BUL Is Nothing Then
ADRES = BUL.Address
Do
If Cells(Target.Row, "E") = Cells(BUL.Row, "E") And Cells(Target.Row, "G") = Cells(BUL.Row, "G") And Cells(Target.Row, "I") = Cells(BUL.Row, "I") And Cells(Target.Row, "J") = Cells(BUL.Row, "J") And Cells(Target.Row, "M") = Cells(BUL.Row, "M") Then
SATIR = IIf(SATIR = "", BUL.Row & Space(1), SATIR & ", " & BUL.Row & Space(1))
End If
Set BUL = Columns(Target.Column).FindNext(BUL)
Loop While Not BUL Is Nothing And BUL.Address <> ADRES
GoTo UYARI
End If: End If: End If
GoTo SON
UYARI: ONAY = MsgBox("Bu kayıt daha önce aşağıdaki satırlarda girilmiştir !" & Chr(10) & Chr(10) & SATIR & Chr(10) & Chr(10) & "İşleme devam etmek istiyor musunuz?", vbYesNo + vbCritical, "DİKKAT !")
If ONAY = vbNo Then
Range("E" & Target.Row, "O" & Target.Row) = ""
Target.Select
Exit Sub: End If
Target.Offset(1, 0).Select
SON:
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
'On Error Resume Next
If Intersect(Target, [G4:G65536]) Is Nothing Then Exit Sub
If Target.Value = "" Then
Range("E" & Target.Row & ":f" & Target.Row).Select
Selection.ClearContents
Range("H" & Target.Row & ":O" & Target.Row).Select
Selection.ClearContents
Cells(Target.Row, "G").Select
Exit Sub
Else
Baglan:
End If
If Intersect(Target, [G4:G65536]) Is Nothing Then Exit Sub
Dim Baglanti As ADODB.Connection
Dim Kayit1 As ADODB.Recordset
Dim FSO As Object
Dim SQLStr, Kaynak1, Kaynak2, Kaynak3, verginosu As String
'***********************************************************************
CurrentRow = Target.Row
CurrentValue = Target.Value
Kaynak1 = "z:\belgelerim\2007 office muhasebe\program_data\veritabani.xls"
Kaynak2 = "d:\belgelerim\2007 office muhasebe\program_data\veritabani.xls"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(Kaynak1) = True Then
Kaynak3 = Kaynak1
ElseIf FSO.FileExists(Kaynak2) = True Then
Kaynak3 = Kaynak2
Else
MsgBox "Veritabani.xls Dosyası Bulunamadı.", vbInformation, "Bilgi"
Exit Sub
End If
verginosu = CurrentValue
SQLStr = "SELECT MÜKELLEFADISOYADI,VDAİRESİ,VERGİNO,ADRESİ FROM [data$] WHERE VERGİNO=" & verginosu
Set Baglanti = CreateObject("ADODB.Connection")
With Baglanti
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Properties("Data Source").Value = Kaynak3
.CursorLocation = adUseServer
.Mode = adModeReadWrite
.Open
End With
If Err = 0 Then
Set Kayit1 = CreateObject("ADODB.Recordset")
With Kayit1
.ActiveConnection = Baglanti
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Source = SQLStr
.Open
End With
'***********************************************************************
If Kayit1.RecordCount = 1 Then
Cells(CurrentRow, "e").Value = Kayit1("MÜKELLEFADISOYADI")
Cells(CurrentRow, "f").Value = Kayit1("VDAİRESİ")
Cells(CurrentRow, "h").Value = Kayit1("ADRESİ")
Else
MsgBox "Aradığınız Kayıt Bulunamadı.", vbInformation, "Bilgi"
UserForm1.Show
End If
Else
Son:
MsgBox "Bağlantı Hatası.Kontrol Ediniz", vbInformation, "Bilgi"
End If
If CBool(Kayit1.State And adStateOpen) = True Then Kayit1.Close
Set Kayit1 = Nothing
If CBool(Baglanti.State And adStateOpen) = True Then Baglanti.Close
Set Baglanti = Nothing
Set FSO = Nothing
Target.Offset(1, 0).Select
End Sub