Merhaba,
aşağıdaki kodlarımda 2 defa on error kullanmam gerek, ancak 2.sini (On Error GoTo yeniotel) dikkate almıyor.
Çözüm önerisi olan var mı?
Private Sub CommandButtonkaydet_Click()
Dim x As Long
Dim y As Long
If ComboBoxacente.Value = "" And ComboBoxotel1 = "" And TextBoxrezno1 = "" Then
MsgBox "Acente, Otel ve Rez No Boş Bırakılamaz"
Else
On Error GoTo yeniacente
'Acente Cari kartına kaydetme
kydt1 = "C:\Users\admin\Desktop\Ufuk\" & ComboBoxacente & ".xlsx"
Workbooks.Open Filename:=kydt1
kydt2 = ActiveWorkbook.Name
For x = 2 To 100000
If ActiveWorkbook.Sheets("Sayfa1").Range("A" & x).Value = "" Then Exit For
Next
ActiveWorkbook.Sheets("Sayfa1").Range("A" & x).Value = TextBoxrezno1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("B" & x).Value = TextBoxmisafir1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("C" & x).Value = TextBoxsatistarihi1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("D" & x).Value = TextBoxcin1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("E" & x).Value = ComboBoxotel1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("F" & x).Value = TextBoxtutar1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("G" & x).Value = ComboBoxodeme1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("H" & x).Value = TextBoxalinan.Text
ActiveWorkbook.Sheets("Sayfa1").Range("I" & x) = ActiveWorkbook.Sheets("Sayfa1").Range("H" & x) - ActiveWorkbook.Sheets("Sayfa1").Range("F" & x)
ActiveWorkbook.Save
ActiveWorkbook.Close
yeniacente:
aktifsayfa = ActiveWorkbook.Name
Windows(aktifsayfa).Activate
SonSat = Cells(Rows.Count, "C").End(3).Row + 1
Sheets("Sabitler").Range("C" & SonSat).Value = ComboBoxacente.Text
newacente = ComboBoxacente.Text
carikart = MsgBox("Acenteye Yeni Cari Kartı Açılsın mı?", vbYesNo)
If carikart = vbYes Then
Workbooks.Add
newacente = ComboBoxacente.Text
ActiveWorkbook.SaveAs Filename:="C:\Users\admin\Desktop\Ufuk\" & newacente & ".xlsx"
acente = ActiveWorkbook.Name
Windows(acente).Activate
Sheets("Sayfa1").Range("A1") = "Rez No"
Sheets("Sayfa1").Range("B1") = " Misafir"
Sheets("Sayfa1").Range("C1") = "Satış Tarihi"
Sheets("Sayfa1").Range("D1") = "C/In Tarihi"
Sheets("Sayfa1").Range("E1") = "Otel"
Sheets("Sayfa1").Range("F1") = "Satış Tutarı"
Sheets("Sayfa1").Range("G1") = "Ödeme Tipi"
Sheets("Sayfa1").Range("H1") = "Alınan Tutar"
Sheets("Sayfa1").Range("I1") = "Kalan Tutar"
Sheets("Sayfa1").Range("N1") = "Acente Bakiye"
Sheets("Sayfa1").Range("N2") = "=SUM(RC[-5]:R[1048574]C[-5])"
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
kydt1 = "C:\Users\admin\Desktop\Ufuk\" & ComboBoxacente & ".xlsx"
Workbooks.Open Filename:=kydt1
kydt2 = ActiveWorkbook.Name
For x = 2 To 100000
If ActiveWorkbook.Sheets("Sayfa1").Range("A" & x).Value = "" Then Exit For
Next
ActiveWorkbook.Sheets("Sayfa1").Range("A" & x).Value = TextBoxrezno1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("B" & x).Value = TextBoxmisafir1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("C" & x).Value = TextBoxsatistarihi1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("D" & x).Value = TextBoxcin1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("E" & x).Value = ComboBoxotel1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("F" & x).Value = TextBoxtutar1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("G" & x).Value = ComboBoxodeme1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("H" & x).Value = TextBoxalinan.Text
ActiveWorkbook.Sheets("Sayfa1").Range("I" & x) = ActiveWorkbook.Sheets("Sayfa1").Range("H" & x) - ActiveWorkbook.Sheets("Sayfa1").Range("F" & x)
ActiveWorkbook.Save
ActiveWorkbook.Close
'Otel cari kartına kaydetme
On Error GoTo yeniotel
kydt3 = "C:\Users\admin\Desktop\Ufuk\" & ComboBoxotel1 & ".xlsx"
Workbooks.Open Filename:=kydt3
For y = 2 To 100000
If ActiveWorkbook.Sheets("Sayfa1").Range("A" & y).Value = "" Then Exit For
Next
ActiveWorkbook.Sheets("Sayfa1").Range("A" & y).Value = TextBoxrezno1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("B" & y).Value = TextBoxmisafir1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("C" & y).Value = TextBoxsatistarihi1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("D" & y).Value = TextBoxcin1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("E" & y).Value = ComboBoxotel1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("F" & y).Value = TextBoxtutar1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("G" & y).Value = ComboBoxodeme1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("H" & y).Value = TextBoxalinan.Text
ActiveWorkbook.Sheets("Sayfa1").Range("I" & y).Value = ComboBoxacente
ActiveWorkbook.Save
ActiveWorkbook.Close
yeniotel:
SonSat = Cells(Rows.Count, "E").End(3).Row + 1
Sheets("Sabitler").Range("E" & SonSat).Value = ComboBoxotel1.Text
newotel = ComboBoxotel1.Text
ocarikart = MsgBox(newotel & " İsminde Yeni Cari Kartı Açılsın mı?", vbYesNo)
If ocarikart = vbYes Then
Workbooks.Add
newotel = ComboBoxotel1.Text
ActiveWorkbook.SaveAs Filename:="C:\Users\admin\Desktop\Ufuk\" & newotel & ".xlsx"
acente = ActiveWorkbook.Name
Windows(acente).Activate
Sheets("Sayfa1").Range("A1") = "Rez No"
Sheets("Sayfa1").Range("B1") = " Misafir"
Sheets("Sayfa1").Range("C1") = "Satış Tarihi"
Sheets("Sayfa1").Range("D1") = "C/In Tarihi"
Sheets("Sayfa1").Range("E1") = "Otel"
Sheets("Sayfa1").Range("F1") = "Satış Tutarı"
Sheets("Sayfa1").Range("G1") = "Ödeme Tipi"
Sheets("Sayfa1").Range("H1") = "Yapılan Ödeme"
Sheets("Sayfa1").Range("I1") = "Acenta"
ActiveWorkbook.Save
ActiveWorkbook.Close
kydt3 = "C:\Users\admin\Desktop\Ufuk\" & ComboBoxotel1 & ".xlsx"
Workbooks.Open Filename:=kydt3
For y = 2 To 100000
If ActiveWorkbook.Sheets("Sayfa1").Range("A" & y).Value = "" Then Exit For
Next
ActiveWorkbook.Sheets("Sayfa1").Range("A" & y).Value = TextBoxrezno1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("B" & y).Value = TextBoxmisafir1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("C" & y).Value = TextBoxsatistarihi1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("D" & y).Value = TextBoxcin1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("E" & y).Value = ComboBoxotel1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("F" & y).Value = TextBoxtutar1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("G" & y).Value = ComboBoxodeme1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("H" & y).Value = TextBoxalinan.Text
ActiveWorkbook.Sheets("Sayfa1").Range("I" & y).Value = ComboBoxacente
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
End If
temizleme = MsgBox("Form Temizlensin mi ?", vbYesNo)
If temizleme = vbYes Then
ComboBoxacente = ""
TextBoxrezno1 = ""
TextBoxmisafir1 = ""
TextBoxsatistarihi1 = ""
TextBoxcin1 = ""
ComboBoxotel1 = ""
TextBoxtutar1 = ""
ComboBoxodeme1 = ""
End If
End Sub
aşağıdaki kodlarımda 2 defa on error kullanmam gerek, ancak 2.sini (On Error GoTo yeniotel) dikkate almıyor.
Çözüm önerisi olan var mı?
Private Sub CommandButtonkaydet_Click()
Dim x As Long
Dim y As Long
If ComboBoxacente.Value = "" And ComboBoxotel1 = "" And TextBoxrezno1 = "" Then
MsgBox "Acente, Otel ve Rez No Boş Bırakılamaz"
Else
On Error GoTo yeniacente
'Acente Cari kartına kaydetme
kydt1 = "C:\Users\admin\Desktop\Ufuk\" & ComboBoxacente & ".xlsx"
Workbooks.Open Filename:=kydt1
kydt2 = ActiveWorkbook.Name
For x = 2 To 100000
If ActiveWorkbook.Sheets("Sayfa1").Range("A" & x).Value = "" Then Exit For
Next
ActiveWorkbook.Sheets("Sayfa1").Range("A" & x).Value = TextBoxrezno1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("B" & x).Value = TextBoxmisafir1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("C" & x).Value = TextBoxsatistarihi1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("D" & x).Value = TextBoxcin1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("E" & x).Value = ComboBoxotel1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("F" & x).Value = TextBoxtutar1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("G" & x).Value = ComboBoxodeme1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("H" & x).Value = TextBoxalinan.Text
ActiveWorkbook.Sheets("Sayfa1").Range("I" & x) = ActiveWorkbook.Sheets("Sayfa1").Range("H" & x) - ActiveWorkbook.Sheets("Sayfa1").Range("F" & x)
ActiveWorkbook.Save
ActiveWorkbook.Close
yeniacente:
aktifsayfa = ActiveWorkbook.Name
Windows(aktifsayfa).Activate
SonSat = Cells(Rows.Count, "C").End(3).Row + 1
Sheets("Sabitler").Range("C" & SonSat).Value = ComboBoxacente.Text
newacente = ComboBoxacente.Text
carikart = MsgBox("Acenteye Yeni Cari Kartı Açılsın mı?", vbYesNo)
If carikart = vbYes Then
Workbooks.Add
newacente = ComboBoxacente.Text
ActiveWorkbook.SaveAs Filename:="C:\Users\admin\Desktop\Ufuk\" & newacente & ".xlsx"
acente = ActiveWorkbook.Name
Windows(acente).Activate
Sheets("Sayfa1").Range("A1") = "Rez No"
Sheets("Sayfa1").Range("B1") = " Misafir"
Sheets("Sayfa1").Range("C1") = "Satış Tarihi"
Sheets("Sayfa1").Range("D1") = "C/In Tarihi"
Sheets("Sayfa1").Range("E1") = "Otel"
Sheets("Sayfa1").Range("F1") = "Satış Tutarı"
Sheets("Sayfa1").Range("G1") = "Ödeme Tipi"
Sheets("Sayfa1").Range("H1") = "Alınan Tutar"
Sheets("Sayfa1").Range("I1") = "Kalan Tutar"
Sheets("Sayfa1").Range("N1") = "Acente Bakiye"
Sheets("Sayfa1").Range("N2") = "=SUM(RC[-5]:R[1048574]C[-5])"
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
kydt1 = "C:\Users\admin\Desktop\Ufuk\" & ComboBoxacente & ".xlsx"
Workbooks.Open Filename:=kydt1
kydt2 = ActiveWorkbook.Name
For x = 2 To 100000
If ActiveWorkbook.Sheets("Sayfa1").Range("A" & x).Value = "" Then Exit For
Next
ActiveWorkbook.Sheets("Sayfa1").Range("A" & x).Value = TextBoxrezno1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("B" & x).Value = TextBoxmisafir1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("C" & x).Value = TextBoxsatistarihi1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("D" & x).Value = TextBoxcin1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("E" & x).Value = ComboBoxotel1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("F" & x).Value = TextBoxtutar1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("G" & x).Value = ComboBoxodeme1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("H" & x).Value = TextBoxalinan.Text
ActiveWorkbook.Sheets("Sayfa1").Range("I" & x) = ActiveWorkbook.Sheets("Sayfa1").Range("H" & x) - ActiveWorkbook.Sheets("Sayfa1").Range("F" & x)
ActiveWorkbook.Save
ActiveWorkbook.Close
'Otel cari kartına kaydetme
On Error GoTo yeniotel
kydt3 = "C:\Users\admin\Desktop\Ufuk\" & ComboBoxotel1 & ".xlsx"
Workbooks.Open Filename:=kydt3
For y = 2 To 100000
If ActiveWorkbook.Sheets("Sayfa1").Range("A" & y).Value = "" Then Exit For
Next
ActiveWorkbook.Sheets("Sayfa1").Range("A" & y).Value = TextBoxrezno1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("B" & y).Value = TextBoxmisafir1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("C" & y).Value = TextBoxsatistarihi1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("D" & y).Value = TextBoxcin1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("E" & y).Value = ComboBoxotel1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("F" & y).Value = TextBoxtutar1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("G" & y).Value = ComboBoxodeme1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("H" & y).Value = TextBoxalinan.Text
ActiveWorkbook.Sheets("Sayfa1").Range("I" & y).Value = ComboBoxacente
ActiveWorkbook.Save
ActiveWorkbook.Close
yeniotel:
SonSat = Cells(Rows.Count, "E").End(3).Row + 1
Sheets("Sabitler").Range("E" & SonSat).Value = ComboBoxotel1.Text
newotel = ComboBoxotel1.Text
ocarikart = MsgBox(newotel & " İsminde Yeni Cari Kartı Açılsın mı?", vbYesNo)
If ocarikart = vbYes Then
Workbooks.Add
newotel = ComboBoxotel1.Text
ActiveWorkbook.SaveAs Filename:="C:\Users\admin\Desktop\Ufuk\" & newotel & ".xlsx"
acente = ActiveWorkbook.Name
Windows(acente).Activate
Sheets("Sayfa1").Range("A1") = "Rez No"
Sheets("Sayfa1").Range("B1") = " Misafir"
Sheets("Sayfa1").Range("C1") = "Satış Tarihi"
Sheets("Sayfa1").Range("D1") = "C/In Tarihi"
Sheets("Sayfa1").Range("E1") = "Otel"
Sheets("Sayfa1").Range("F1") = "Satış Tutarı"
Sheets("Sayfa1").Range("G1") = "Ödeme Tipi"
Sheets("Sayfa1").Range("H1") = "Yapılan Ödeme"
Sheets("Sayfa1").Range("I1") = "Acenta"
ActiveWorkbook.Save
ActiveWorkbook.Close
kydt3 = "C:\Users\admin\Desktop\Ufuk\" & ComboBoxotel1 & ".xlsx"
Workbooks.Open Filename:=kydt3
For y = 2 To 100000
If ActiveWorkbook.Sheets("Sayfa1").Range("A" & y).Value = "" Then Exit For
Next
ActiveWorkbook.Sheets("Sayfa1").Range("A" & y).Value = TextBoxrezno1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("B" & y).Value = TextBoxmisafir1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("C" & y).Value = TextBoxsatistarihi1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("D" & y).Value = TextBoxcin1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("E" & y).Value = ComboBoxotel1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("F" & y).Value = TextBoxtutar1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("G" & y).Value = ComboBoxodeme1.Text
ActiveWorkbook.Sheets("Sayfa1").Range("H" & y).Value = TextBoxalinan.Text
ActiveWorkbook.Sheets("Sayfa1").Range("I" & y).Value = ComboBoxacente
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
End If
temizleme = MsgBox("Form Temizlensin mi ?", vbYesNo)
If temizleme = vbYes Then
ComboBoxacente = ""
TextBoxrezno1 = ""
TextBoxmisafir1 = ""
TextBoxsatistarihi1 = ""
TextBoxcin1 = ""
ComboBoxotel1 = ""
TextBoxtutar1 = ""
ComboBoxodeme1 = ""
End If
End Sub