- Katılım
- 17 Kasım 2019
- Mesajlar
- 43
- Excel Vers. ve Dili
- 2019,Türkçe
Merhabalar arkadaşlar;
aşağıda eklediğim gibi bir veri kayıt makrosu var sorunsuz çalışmakta lakin bu makroya her yeni kayıt için yeni bir sıra numarası 1. Sutuna eklemesini istiyorum nereye ekleyeceğimi bilemedim yardımcı olursanız sevinirim
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("OTELDEKİLER")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a Name number
If Trim(Me.TextBoxad.Value) = "" Then
Me.TextBoxad.SetFocus
MsgBox "Lütfen İsim Girin"
Exit Sub
End If
If Trim(Me.TextBoxsoyad.Value) = "" Then
Me.TextBoxsoyad.SetFocus
MsgBox "Lütfen Soyisim Girin"
Exit Sub
End If
If Trim(Me.TextBoxadet.Value) = "" Then
Me.TextBoxadet.SetFocus
MsgBox "Lütfen Adet Girin"
Exit Sub
End If
If Trim(Me.TextBoxmarka.Value) = "" Then
Me.TextBoxmarka.SetFocus
MsgBox "Lütfen Marka Girin"
Exit Sub
End If
If Trim(Me.TextBoxebat.Value) = "" Then
Me.TextBoxebat.SetFocus
MsgBox "Lütfen Ebat Girin"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 2).Value = Me.TextBoxad.Value
ws.Cells(iRow, 3).Value = Me.TextBoxsoyad.Value
ws.Cells(iRow, 4).Value = Me.TextBoxtel.Value
ws.Cells(iRow, 5).Value = Me.TextBoxplaka.Value
ws.Cells(iRow, 6).Value = Me.TextBoxebat.Value
ws.Cells(iRow, 7).Value = Me.TextBoxmarka.Value
ws.Cells(iRow, 8).Value = Me.TextBoxdesen.Value
ws.Cells(iRow, 9).Value = Me.TextBoxadet.Value
ws.Cells(iRow, 10).Value = Me.TextBoxtarih.Value
MsgBox "KAYIT YAPILDI.", vbOKOnly + vbInformation
'clear the data
Me.TextBoxad.Value = ""
Me.TextBoxsoyad.Value = ""
Me.TextBoxtel.Value = ""
Me.TextBoxplaka.Value = ""
Me.TextBoxebat.Value = ""
Me.TextBoxmarka.Value = ""
Me.TextBoxdesen.Value = ""
Me.TextBoxadet.Value = ""
Me.TextBoxtarih.Value = ""
Me.TextBoxad.SetFocus
Sayfa1.Visible = True
Sayfa1.Activate
UserForm1.Hide
UserForm2.Hide
End Sub
aşağıda eklediğim gibi bir veri kayıt makrosu var sorunsuz çalışmakta lakin bu makroya her yeni kayıt için yeni bir sıra numarası 1. Sutuna eklemesini istiyorum nereye ekleyeceğimi bilemedim yardımcı olursanız sevinirim
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("OTELDEKİLER")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a Name number
If Trim(Me.TextBoxad.Value) = "" Then
Me.TextBoxad.SetFocus
MsgBox "Lütfen İsim Girin"
Exit Sub
End If
If Trim(Me.TextBoxsoyad.Value) = "" Then
Me.TextBoxsoyad.SetFocus
MsgBox "Lütfen Soyisim Girin"
Exit Sub
End If
If Trim(Me.TextBoxadet.Value) = "" Then
Me.TextBoxadet.SetFocus
MsgBox "Lütfen Adet Girin"
Exit Sub
End If
If Trim(Me.TextBoxmarka.Value) = "" Then
Me.TextBoxmarka.SetFocus
MsgBox "Lütfen Marka Girin"
Exit Sub
End If
If Trim(Me.TextBoxebat.Value) = "" Then
Me.TextBoxebat.SetFocus
MsgBox "Lütfen Ebat Girin"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 2).Value = Me.TextBoxad.Value
ws.Cells(iRow, 3).Value = Me.TextBoxsoyad.Value
ws.Cells(iRow, 4).Value = Me.TextBoxtel.Value
ws.Cells(iRow, 5).Value = Me.TextBoxplaka.Value
ws.Cells(iRow, 6).Value = Me.TextBoxebat.Value
ws.Cells(iRow, 7).Value = Me.TextBoxmarka.Value
ws.Cells(iRow, 8).Value = Me.TextBoxdesen.Value
ws.Cells(iRow, 9).Value = Me.TextBoxadet.Value
ws.Cells(iRow, 10).Value = Me.TextBoxtarih.Value
MsgBox "KAYIT YAPILDI.", vbOKOnly + vbInformation
'clear the data
Me.TextBoxad.Value = ""
Me.TextBoxsoyad.Value = ""
Me.TextBoxtel.Value = ""
Me.TextBoxplaka.Value = ""
Me.TextBoxebat.Value = ""
Me.TextBoxmarka.Value = ""
Me.TextBoxdesen.Value = ""
Me.TextBoxadet.Value = ""
Me.TextBoxtarih.Value = ""
Me.TextBoxad.SetFocus
Sayfa1.Visible = True
Sayfa1.Activate
UserForm1.Hide
UserForm2.Hide
End Sub
