Aşağıdaki kodda farklı bir excel dosyasından veri çekiyorum ve aynı dosyaya veri yazdırıp çıkıyorum. Ancak verileri kaydederken "dosya zaten açık" uyarısı veriyor. Oysa verileri çektikten sona dosyayı kapatıyorum. "Set Proformakayit = Workbooks.Open(Proformaveri, False, False)" satırı hata veriyor.
Private Sub CommandButton1_Click()
YeniKisi.Show
End Sub
Private Sub CommandButton2_Click()
Dim dizi(1 To 50000, 1 To 7)
Dim iRow As Long
Dim Proformakayit As Workbook
Proformaveri = ThisWorkbook.Path & "\" & "proformalar" & "\" & "proforma.xlsx"
Set Proformakayit = Workbooks.Open(Proformaveri, False, False)
Dim ws As Worksheet
Set ws = Worksheets("Yeni_Proforma")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'TarihKontrol
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Lütfen Geçerli Bir Tarih Giriniz"
Exit Sub
End If
'Proforma No Kontrol
If Trim(Me.TextBox3.Value) = "" Then
Me.TextBox3.SetFocus
MsgBox "Lütfen Geçerli Bir Proforma No Yazınız"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.TextBox3.Value
ws.Cells(iRow, 3).Value = Me.ComboBox1.Value
ws.Cells(iRow, 4).Value = Me.ComboBox2.Value
ws.Cells(iRow, 2).Value = Me.TextBox1.Value
ws.Cells(iRow, 5).Value = Me.TextBox5.Value
ws.Cells(iRow, 6).Value = Me.TextBox6.Value
'clear the data
Me.TextBox1.Value = ""
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
If ActiveWorkbook.FullName = "Proformakayit" Then
Application.Dialogs(xlDialogSaveAs).Show
ActiveWorkbook.Close
Else
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
Unload Yeni_Proforma
End Sub
Private Sub ComboBox1_Change()
Dim Proformakayit As Workbook
Proformaveri = ThisWorkbook.Path & "\" & "proformalar" & "\" & "proforma.xlsx"
Set Proformakayit = Workbooks.Open(Proformaveri, False, False)
Dim ws As Worksheet
Set ws = Worksheets("Kisiler")
With ws
For Each bul In .Range("A2:A" & ws.Range("A65536").End(3).Row)
If CStr(bul.Value) = CStr(ComboBox1.Value) Then
TextBox5.Value = bul.Offset(0, 1).Value
TextBox6.Value = bul.Offset(0, 6).Value
End If
Next bul
End With
End Sub
Private Sub CommandButton1_Click()
YeniKisi.Show
End Sub
Private Sub CommandButton2_Click()
Dim dizi(1 To 50000, 1 To 7)
Dim iRow As Long
Dim Proformakayit As Workbook
Proformaveri = ThisWorkbook.Path & "\" & "proformalar" & "\" & "proforma.xlsx"
Set Proformakayit = Workbooks.Open(Proformaveri, False, False)
Dim ws As Worksheet
Set ws = Worksheets("Yeni_Proforma")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'TarihKontrol
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Lütfen Geçerli Bir Tarih Giriniz"
Exit Sub
End If
'Proforma No Kontrol
If Trim(Me.TextBox3.Value) = "" Then
Me.TextBox3.SetFocus
MsgBox "Lütfen Geçerli Bir Proforma No Yazınız"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.TextBox3.Value
ws.Cells(iRow, 3).Value = Me.ComboBox1.Value
ws.Cells(iRow, 4).Value = Me.ComboBox2.Value
ws.Cells(iRow, 2).Value = Me.TextBox1.Value
ws.Cells(iRow, 5).Value = Me.TextBox5.Value
ws.Cells(iRow, 6).Value = Me.TextBox6.Value
'clear the data
Me.TextBox1.Value = ""
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
If ActiveWorkbook.FullName = "Proformakayit" Then
Application.Dialogs(xlDialogSaveAs).Show
ActiveWorkbook.Close
Else
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
Unload Yeni_Proforma
End Sub
Private Sub ComboBox1_Change()
Dim Proformakayit As Workbook
Proformaveri = ThisWorkbook.Path & "\" & "proformalar" & "\" & "proforma.xlsx"
Set Proformakayit = Workbooks.Open(Proformaveri, False, False)
Dim ws As Worksheet
Set ws = Worksheets("Kisiler")
With ws
For Each bul In .Range("A2:A" & ws.Range("A65536").End(3).Row)
If CStr(bul.Value) = CStr(ComboBox1.Value) Then
TextBox5.Value = bul.Offset(0, 1).Value
TextBox6.Value = bul.Offset(0, 6).Value
End If
Next bul
End With
End Sub
