comboboxda seçilen sayfaya göre listviewde sayfa verileri görülüyor ben sil ve değiştir komutu eklemeye çalıştım ama hata veriyor yardım ederseniz sevinirim
Private Sub CommandButton4_Click()
Sheets(Me.ComboBox1.Text).Select
Set S1 = Sheets(Me.ComboBox1.Text)
Dim sat%
On Error GoTo hata
cevap = MsgBox("SİLMEK İSTEDİĞİNİZDEN EMİNMİSİNİZ ?", vbYesNo, "SİLME ONAYI")
If cevap = vbNo Then
For tem = 1 To 5
Controls("textbox" & tem) = Empty
Next
TextBox1.Enabled = True
TextBox1.SetFocus
Exit Sub
End If
Dim bak As Range
Dim syd As String
Dim Satir As Long
Set S1 = ThisWorkbook.Worksheets("me.combobox1.text")
If cevap = vbYes Then
SAY = S1.Cells(65536, "a").End(3).Row
For Each bak In S1.Range("a2:a" & SAY)
ad = S1.Range(bak.Offset(0, 0).Address).Value
syd = S1.Range(bak.Offset(0, 1).Address).Value
' MsgBox ad & Syd
If StrConv(ad, vbUpperCase) = StrConv(TextBox2.Text, vbUpperCase) Then
If StrConv(syd, vbUpperCase) = StrConv(TextBox3.Text, vbUpperCase) Then
bak.Select
S1.Range(ActiveCell.Offset(0, -1).Address(False, False) & ":" & ActiveCell.Offset(0, 5).Address(False, False)).Delete Shift:=xlUp
MsgBox "VERİNİZ SİLİNDİ", vbInformation, "S İ L"
Exit For
' Exit Sub
End If
End If
Next bak
SAY = S1.Cells(65536, "b").End(3).Row
For i = 1 To SAY - 1
Cells(i + 1, 1) = i
Next i
End If
S1.Range("A2:e65536").Select
Selection.Sort Key1:=S1.Range("A2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ListView1.ListItems.Clear
SAY = S1.Cells(65536, "A").End(3).Row
ListView1.ListItems.Clear
For i = 2 To SAY
Set liste1 = Me.ListView1.ListItems.Add(, , S1.Cells(i, "A").Value)
liste1.SubItems(1) = S1.Cells(i, "B").Value
liste1.SubItems(2) = S1.Cells(i, "C").Value
liste1.SubItems(3) = S1.Cells(i, "D").Value
liste1.SubItems(4) = S1.Cells(i, "E").Value
If Left(S1.Cells(i + 1, 2), 1) = "*" Then
Me.ListView1.ListItems(i).ListSubItems(1).ForeColor = vbBlue
Me.ListView1.ListItems(i).ForeColor = vbBlue
End If
If Left(S1.Cells(i + 1, 2), 1) = "-" Then
Me.ListView1.ListItems(i).ListSubItems(1).ForeColor = vbRed
Me.ListView1.ListItems(i).ForeColor = vbRed
End If
Next i
ListView1.FullRowSelect = True
ListView1.Gridlines = True
sayı = i - 1
Label1 = sayı & " ADET"
For tem = 1 To 19
Controls("textbox" & tem) = Empty
Next
TextBox1.Enabled = True
CommandButton1.Enabled = True
CommandButton4.Enabled = False
TextBox1.SetFocus
TextBox20.Text = ""
hata:
End Sub
Private Sub CommandButton5_Click()
Dim S1 As Worksheet
Set S1 = Sheets("Me.ComboBox1.Text").Select
'D E Ğ İ Ş T İ R
If TextBox1.Text = "" Then
MsgBox "LÜTFEN ÖNCE LİSTEDEN BİR SEÇİM YAPIN", vbCritical, "D İ K K A T"
ListView1.SetFocus
Exit Sub
End If
On Error Resume Next
If TextBox1.Text = "" Then
MsgBox ("Label1.Text")
TextBox1.SetFocus
Exit Sub
ElseIf TextBox2.Text = "" Then
MsgBox ("Label2.Text"), vbCritical, ("BÖLÜM BOŞ")
TextBox2.SetFocus
Exit Sub
End If
Sheets("Me.ComboBox1.Text").Select
Set S1 = Sheets("Me.ComboBox1.Text")
Dim sat%
On Error GoTo hata
cevap = MsgBox("DEĞİŞTİRMEK İSTEDİĞİNİZDEN EMİNMİSİNİZ ?", vbYesNo, "DEĞİŞTİRME ONAYI")
If cevap = vbNo Then
For tem = 1 To 5
Controls("textbox" & tem) = Empty
Next
TextBox1.Enabled = True
TextBox1.SetFocus
Exit Sub
End If
If cevap = vbYes Then
Dim syd As String
Dim bak As Range
SAY = S1.Cells(65536, "B").End(3).Row
For Each bak In S1.Range("B2:B" & SAY)
ad = S1.Range(bak.Offset(0, 0).Address).Value
syd = S1.Range(bak.Offset(0, 1).Address).Value
' MsgBox ad & Syd
If StrConv(ad, vbUpperCase) = StrConv(TextBox1.Text, vbUpperCase) Then
If StrConv(syd, vbUpperCase) = StrConv(TextBox2.Text, vbUpperCase) Then
bak.Select
S1.Range(bak.Offset(0, 0).Address).Value = TextBox1.Text
S1.Range(bak.Offset(0, 1).Address).Value = TextBox2.Text
S1.Range(bak.Offset(0, 2).Address).Value = TextBox3.Text
S1.Range(bak.Offset(0, 3).Address).Value = TextBox4.Text
S1.Range(bak.Offset(0, 4).Address).Value = TextBox5.Text
MsgBox "VERİNİZ DEĞİŞTİRİLDİ", vbInformation, "YENİLEME"
Exit For
' Exit Sub
End If
End If
Next bak
End If
S1.Range("A2:S65536").Select
Selection.Sort Key1:=S1.Range("A2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
SAY = S1.Cells(65536, "A").End(3).Row
ListView1.ListItems.Clear
For i = 2 To SAY
Set liste1 = Me.ListView1.ListItems.Add(, , S1.Cells(i, "A").Value)
liste1.SubItems(1) = S1.Cells(i, "B").Value
liste1.SubItems(2) = S1.Cells(i, "C").Value
liste1.SubItems(3) = S1.Cells(i, "D").Value
liste1.SubItems(4) = S1.Cells(i, "E").Value
'eğer hücre başında (*) işareti var ise satırı mavi renklendir
If Left(S1.Cells(i + 1, 2), 1) = "*" Then
liste1.ListItems(i - 1).ListSubItems(1).ForeColor = vbBlue
liste1.ListItems(i - 1).ForeColor = vbBlue
End If
'eğer hücre başında (-) işareti var ise satırı kırmızı renklendir
If Left(S1.Cells(i + 1, 2), 1) = "-" Then
liste1.ListItems(i - 1).ListSubItems(1).ForeColor = vbRed
liste1.ListItems(i - 1).ForeColor = vbRed
End If
Next i
ListView1.FullRowSelect = True
ListView1.Gridlines = True
MsgBox " ADI = " & TextBox1 & Chr(10) & " SOYADI = " _
& TextBox2, vbInformation, "DEĞİŞTİRME BİLGİLERİ"
sayı = C - 1
Label1 = sayı & " ADET"
For tem = 1 To 5
Controls("textbox" & tem) = Empty
Next
TextBox1.Enabled = True
CommandButton1.Enabled = True
CommandButton4.Enabled = False
TextBox1.SetFocus
TextBox5.Text = ""
hata:
End Sub
Private Sub CommandButton4_Click()
Sheets(Me.ComboBox1.Text).Select
Set S1 = Sheets(Me.ComboBox1.Text)
Dim sat%
On Error GoTo hata
cevap = MsgBox("SİLMEK İSTEDİĞİNİZDEN EMİNMİSİNİZ ?", vbYesNo, "SİLME ONAYI")
If cevap = vbNo Then
For tem = 1 To 5
Controls("textbox" & tem) = Empty
Next
TextBox1.Enabled = True
TextBox1.SetFocus
Exit Sub
End If
Dim bak As Range
Dim syd As String
Dim Satir As Long
Set S1 = ThisWorkbook.Worksheets("me.combobox1.text")
If cevap = vbYes Then
SAY = S1.Cells(65536, "a").End(3).Row
For Each bak In S1.Range("a2:a" & SAY)
ad = S1.Range(bak.Offset(0, 0).Address).Value
syd = S1.Range(bak.Offset(0, 1).Address).Value
' MsgBox ad & Syd
If StrConv(ad, vbUpperCase) = StrConv(TextBox2.Text, vbUpperCase) Then
If StrConv(syd, vbUpperCase) = StrConv(TextBox3.Text, vbUpperCase) Then
bak.Select
S1.Range(ActiveCell.Offset(0, -1).Address(False, False) & ":" & ActiveCell.Offset(0, 5).Address(False, False)).Delete Shift:=xlUp
MsgBox "VERİNİZ SİLİNDİ", vbInformation, "S İ L"
Exit For
' Exit Sub
End If
End If
Next bak
SAY = S1.Cells(65536, "b").End(3).Row
For i = 1 To SAY - 1
Cells(i + 1, 1) = i
Next i
End If
S1.Range("A2:e65536").Select
Selection.Sort Key1:=S1.Range("A2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ListView1.ListItems.Clear
SAY = S1.Cells(65536, "A").End(3).Row
ListView1.ListItems.Clear
For i = 2 To SAY
Set liste1 = Me.ListView1.ListItems.Add(, , S1.Cells(i, "A").Value)
liste1.SubItems(1) = S1.Cells(i, "B").Value
liste1.SubItems(2) = S1.Cells(i, "C").Value
liste1.SubItems(3) = S1.Cells(i, "D").Value
liste1.SubItems(4) = S1.Cells(i, "E").Value
If Left(S1.Cells(i + 1, 2), 1) = "*" Then
Me.ListView1.ListItems(i).ListSubItems(1).ForeColor = vbBlue
Me.ListView1.ListItems(i).ForeColor = vbBlue
End If
If Left(S1.Cells(i + 1, 2), 1) = "-" Then
Me.ListView1.ListItems(i).ListSubItems(1).ForeColor = vbRed
Me.ListView1.ListItems(i).ForeColor = vbRed
End If
Next i
ListView1.FullRowSelect = True
ListView1.Gridlines = True
sayı = i - 1
Label1 = sayı & " ADET"
For tem = 1 To 19
Controls("textbox" & tem) = Empty
Next
TextBox1.Enabled = True
CommandButton1.Enabled = True
CommandButton4.Enabled = False
TextBox1.SetFocus
TextBox20.Text = ""
hata:
End Sub
Private Sub CommandButton5_Click()
Dim S1 As Worksheet
Set S1 = Sheets("Me.ComboBox1.Text").Select
'D E Ğ İ Ş T İ R
If TextBox1.Text = "" Then
MsgBox "LÜTFEN ÖNCE LİSTEDEN BİR SEÇİM YAPIN", vbCritical, "D İ K K A T"
ListView1.SetFocus
Exit Sub
End If
On Error Resume Next
If TextBox1.Text = "" Then
MsgBox ("Label1.Text")
TextBox1.SetFocus
Exit Sub
ElseIf TextBox2.Text = "" Then
MsgBox ("Label2.Text"), vbCritical, ("BÖLÜM BOŞ")
TextBox2.SetFocus
Exit Sub
End If
Sheets("Me.ComboBox1.Text").Select
Set S1 = Sheets("Me.ComboBox1.Text")
Dim sat%
On Error GoTo hata
cevap = MsgBox("DEĞİŞTİRMEK İSTEDİĞİNİZDEN EMİNMİSİNİZ ?", vbYesNo, "DEĞİŞTİRME ONAYI")
If cevap = vbNo Then
For tem = 1 To 5
Controls("textbox" & tem) = Empty
Next
TextBox1.Enabled = True
TextBox1.SetFocus
Exit Sub
End If
If cevap = vbYes Then
Dim syd As String
Dim bak As Range
SAY = S1.Cells(65536, "B").End(3).Row
For Each bak In S1.Range("B2:B" & SAY)
ad = S1.Range(bak.Offset(0, 0).Address).Value
syd = S1.Range(bak.Offset(0, 1).Address).Value
' MsgBox ad & Syd
If StrConv(ad, vbUpperCase) = StrConv(TextBox1.Text, vbUpperCase) Then
If StrConv(syd, vbUpperCase) = StrConv(TextBox2.Text, vbUpperCase) Then
bak.Select
S1.Range(bak.Offset(0, 0).Address).Value = TextBox1.Text
S1.Range(bak.Offset(0, 1).Address).Value = TextBox2.Text
S1.Range(bak.Offset(0, 2).Address).Value = TextBox3.Text
S1.Range(bak.Offset(0, 3).Address).Value = TextBox4.Text
S1.Range(bak.Offset(0, 4).Address).Value = TextBox5.Text
MsgBox "VERİNİZ DEĞİŞTİRİLDİ", vbInformation, "YENİLEME"
Exit For
' Exit Sub
End If
End If
Next bak
End If
S1.Range("A2:S65536").Select
Selection.Sort Key1:=S1.Range("A2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
SAY = S1.Cells(65536, "A").End(3).Row
ListView1.ListItems.Clear
For i = 2 To SAY
Set liste1 = Me.ListView1.ListItems.Add(, , S1.Cells(i, "A").Value)
liste1.SubItems(1) = S1.Cells(i, "B").Value
liste1.SubItems(2) = S1.Cells(i, "C").Value
liste1.SubItems(3) = S1.Cells(i, "D").Value
liste1.SubItems(4) = S1.Cells(i, "E").Value
'eğer hücre başında (*) işareti var ise satırı mavi renklendir
If Left(S1.Cells(i + 1, 2), 1) = "*" Then
liste1.ListItems(i - 1).ListSubItems(1).ForeColor = vbBlue
liste1.ListItems(i - 1).ForeColor = vbBlue
End If
'eğer hücre başında (-) işareti var ise satırı kırmızı renklendir
If Left(S1.Cells(i + 1, 2), 1) = "-" Then
liste1.ListItems(i - 1).ListSubItems(1).ForeColor = vbRed
liste1.ListItems(i - 1).ForeColor = vbRed
End If
Next i
ListView1.FullRowSelect = True
ListView1.Gridlines = True
MsgBox " ADI = " & TextBox1 & Chr(10) & " SOYADI = " _
& TextBox2, vbInformation, "DEĞİŞTİRME BİLGİLERİ"
sayı = C - 1
Label1 = sayı & " ADET"
For tem = 1 To 5
Controls("textbox" & tem) = Empty
Next
TextBox1.Enabled = True
CommandButton1.Enabled = True
CommandButton4.Enabled = False
TextBox1.SetFocus
TextBox5.Text = ""
hata:
End Sub