Function Sayfaad(syfad As String) As Boolean
Dim ws As Worksheet
On Error Resume Next
Set ws = Worksheets(syfad)
If Not ws Is Nothing Then Sayfaad = True
End Function
Bu kodu userform4 e ekleyin.Alttaki koduda ilgili kodla değiştirin.
Private Sub CommandButton10_Click()
ActiveWorkbook.Unprotect "123"
If TextBox1 = "" Then
MsgBox "...!!!.LÜTFEN ADI SOYADI GİRİNİZ.!!!...", vbInformation
Exit Sub: End If
If Sayfaad(Me.TextBox1.Value) = True Then
MsgBox "...!!!.AYNİ İSMİMDE KAYIT VAR. AYNİ İSİMDE İKİ KAYIT OLMAZ.!!!...", vbInformation
Exit Sub
End If
Sheets("ŞABLON").Copy After:=Worksheets(Worksheets.Count)
ActiveSheet.Unprotect "123"
ActiveSheet.Name = (TextBox1.Text)
ActiveSheet.Range("a1").Value = (TextBox1.Value)
ActiveSheet.Range("c2").Value = (TextBox2.Value)
ActiveSheet.Range("c3").Value = (TextBox3.Value)
ActiveSheet.Range("c4").Value = (TextBox4.Value)
ActiveSheet.Range("c5").Value = (TextBox5.Value)
'Call VeriSayfasinaKaydet
MsgBox ("YENİ KİŞİ EKLENDİ.")
Me.ListBox2.Clear
For A = 4 To Sheets.Count
ListBox2.AddItem Sheets(A).Name
'ListBox daki listeyi sıralama'
Dim vaItems As Variant
Dim i As Long, j As Long
Dim vTemp As Variant
'Put the items in a variant array
vaItems = Me.ListBox2.List
'Steal code from John Walkenbach’s Excel Power Programming
'with Vba to sort the array
For i = LBound(vaItems, 1) To UBound(vaItems, 1) - 1
For j = i + 1 To UBound(vaItems, 1)
If vaItems(i, 0) > vaItems(j, 0) Then
vTemp = vaItems(i, 0)
vaItems(i, 0) = vaItems(j, 0)
vaItems(j, 0) = vTemp
End If
Next j
Next i
ActiveWorkbook.Unprotect "123"
ActiveWorkbook.Protect "123"
ActiveSheet.Unprotect "123"
ActiveSheet.Protect "123"
CommandButton2_Click
'Clear the listbox
Me.ListBox2.Clear
'Add the sorted array back to the listbox
For i = LBound(vaItems, 1) To UBound(vaItems, 1)
Me.ListBox2.AddItem vaItems(i, 0)
ComboBox1.RowSource = "Liste!l1:l2"
'----------------------------------EKLEDİĞİM-------------------------SONU
TextBox1.Text = [a1]
TextBox2.Text = [C1]
TextBox3.Text = [C2]
TextBox4.Text = [C3]
Next i
Next
CommandButton2_Click
TextBox1.Text = [Z1]
TextBox1.Text = [a1]
TextBox2.Text = [C2]
TextBox3.Text = [C3]
TextBox4.Text = [C4]
Me.TextBox1 = ""
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.TextBox4 = ""
Me.TextBox5 = ""
End Sub