• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Mevcut Verileri Güncellemek.

ahmed_ummu

Altın Üye
Katılım
28 Mart 2011
Mesajlar
777
Excel Vers. ve Dili
Excel 2010 Professional Plus 64 Bit
İyi akşamşar arkadaşlar.

Aşağıdaki kod ile mevcut belgileri değiştirmek istiyorum ama kodu çalıştırınca herhangi bir hata vermiyor ama eski verileri yeni veriler ile de değiştirmiyor.
Yardımcı olursanız sevinirim.


Private Sub CommandButton4_Click()

' Verileri güncelle
ActiveCell.Offset(0, 2).Value = TextBox3.Value
ActiveCell.Offset(0, 3).Value = TextBox4.Value
ActiveCell.Offset(0, 4).Value = TextBox5.Value
ActiveCell.Offset(0, 5).Value = TextBox259.Value
ActiveCell.Offset(0, 6).Value = TextBox256.Value
ActiveCell.Offset(0, 7).Value = TextBox257.Value
ActiveCell.Offset(0, 8).Value = TextBox253.Value
ActiveCell.Offset(0, 9).Value = TextBox254.Value
ActiveCell.Offset(0, 10).Value = TextBox258.Value
ActiveCell.Offset(0, 11).Value = TextBox260.Value
ActiveCell.Offset(0, 12).Value = TextBox261.Value
ActiveCell.Offset(0, 13).Value = TextBox252.Value

' Sayfayı yenile
Application.ScreenUpdating = True
ActiveSheet.Calculate
DoEvents

' ListBox güncelleme
Sheets("veri").Select
Range("a4").Select
' ListBox1.Clear
With ListBox1
.ColumnCount = 15
.ColumnWidths = "20;28;93;60;40;60;60;70;45;45;100;30;30;30;30"
.RowSource = "a4:n" & WorksheetFunction.Max(4, Cells(Rows.Count, "a").End(xlUp).Row)
End With
End Sub
 
Kod:
    With ActiveCell
        .Offset(0, 2).Value = TextBox3.Value
        .Offset(0, 3).Value = TextBox4.Value
        .Offset(0, 4).Value = TextBox5.Value
        .Offset(0, 5).Value = TextBox259.Value
        .Offset(0, 6).Value = TextBox256.Value
        .Offset(0, 7).Value = TextBox257.Value
        .Offset(0, 8).Value = TextBox253.Value
        .Offset(0, 9).Value = TextBox254.Value
        .Offset(0, 10).Value = TextBox258.Value
        .Offset(0, 11).Value = TextBox260.Value
        .Offset(0, 12).Value = TextBox261.Value
        .Offset(0, 13).Value = TextBox252.Value
    End With
 
    Application.ScreenUpdating = False
    
    Set ws = Sheets("veri") 'sayfa ismini girin
    
    sonSatir = Application.WorksheetFunction.Max(4, ws.Cells(ws.Rows.Count, "A").End(xlUp).Row)
    
    With ListBox1
        .ColumnCount = 15
        .ColumnWidths = "20;28;93;60;40;60;60;70;45;45;100;30;30;30;30"
        .RowSource = "veri!A4:N" & sonSatir
    End With
    Application.ScreenUpdating = True
 
Kod:
    With ActiveCell
        .Offset(0, 2).Value = TextBox3.Value
        .Offset(0, 3).Value = TextBox4.Value
        .Offset(0, 4).Value = TextBox5.Value
        .Offset(0, 5).Value = TextBox259.Value
        .Offset(0, 6).Value = TextBox256.Value
        .Offset(0, 7).Value = TextBox257.Value
        .Offset(0, 8).Value = TextBox253.Value
        .Offset(0, 9).Value = TextBox254.Value
        .Offset(0, 10).Value = TextBox258.Value
        .Offset(0, 11).Value = TextBox260.Value
        .Offset(0, 12).Value = TextBox261.Value
        .Offset(0, 13).Value = TextBox252.Value
    End With

    Application.ScreenUpdating = False
  
    Set ws = Sheets("veri") 'sayfa ismini girin
  
    sonSatir = Application.WorksheetFunction.Max(4, ws.Cells(ws.Rows.Count, "A").End(xlUp).Row)
  
    With ListBox1
        .ColumnCount = 15
        .ColumnWidths = "20;28;93;60;40;60;60;70;45;45;100;30;30;30;30"
        .RowSource = "veri!A4:N" & sonSatir
    End With
    Application.ScreenUpdating = True
Sayın osman06turgut kodlar için teşekkür ederim. Kodu çalıştırınca herhangi bir hata vermedi Sadece .Offset(0, 2).Value = TextBox3.Value kod satırını güncelledi diğer satırları güncellemedi.
 
Textbox1-2-3-4 devam eder bu bir tanımlamadır. Form üzerinde sanmıyorum ki 252 adet Textbox var! Bunun en basit çözümü Kod Görüntülemede "Form" ekranınızda bulunan TextBox tanımlamalarını kontrol etmenizdir.
 
Textbox1-2-3-4 devam eder bu bir tanımlamadır. Form üzerinde sanmıyorum ki 252 adet Textbox var! Bunun en basit çözümü Kod Görüntülemede "Form" ekranınızda bulunan TextBox tanımlamalarını kontrol etmenizdir.

Sayın osman06turgut ilginize teşekkür ederim. Dosyamı göndersem onun üzerinde bakabilir misiniz.

Exceli aç butonu ile exceli açabilirsiniz. Kırmızı renkli buton. Kodlarım yine kırmızı renkli Kayıt Güncelle adlı buton da. Yardımcı olursanız sevinirim.
 

Ekli dosyalar

Bunu denermisiniz.

CSS:
Private Sub CommandButton4_Click()


'sirano = ListBox1.List(ListBox1.ListIndex, 0) + 3
sirano = ListBox1.ListIndex + 4
ListBox1.RowSource = ""

Worksheets("veri").Cells(sirano, 3).Value = TextBox3.Value
Worksheets("veri").Cells(sirano, 4).Value = TextBox4.Value
Worksheets("veri").Cells(sirano, 5).Value = TextBox5.Value
Worksheets("veri").Cells(sirano, 6).Value = TextBox259.Value
Worksheets("veri").Cells(sirano, 7).Value = TextBox257.Value
Worksheets("veri").Cells(sirano, 8).Value = TextBox253.Value
Worksheets("veri").Cells(sirano, 9).Value = TextBox254.Value
Worksheets("veri").Cells(sirano, 10).Value = TextBox258.Value
Worksheets("veri").Cells(sirano, 11).Value = TextBox260.Value
Worksheets("veri").Cells(sirano, 12).Value = TextBox261.Value
Worksheets("veri").Cells(sirano, 13).Value = TextBox252.Value

With ListBox1
.ColumnCount = 15
.ColumnWidths = "20;28;93;60;40;60;60;70;45;45;100;30;30;30;30"
.RowSource = "a4:n" & WorksheetFunction.Max(4, Cells(Rows.Count, "a").End(xlUp).Row)
End With
ListBox1.ListIndex = sirano - 4
   
End Sub
 
Son düzenleme:
Bunu denermisiniz.

CSS:
Private Sub CommandButton4_Click()


'sirano = ListBox1.List(ListBox1.ListIndex, 0) + 3
sirano = ListBox1.ListIndex + 4
ListBox1.RowSource = ""

Worksheets("veri").Cells(sirano, 3).Value = TextBox3.Value
Worksheets("veri").Cells(sirano, 4).Value = TextBox4.Value
Worksheets("veri").Cells(sirano, 5).Value = TextBox5.Value
Worksheets("veri").Cells(sirano, 6).Value = TextBox259.Value
Worksheets("veri").Cells(sirano, 7).Value = TextBox257.Value
Worksheets("veri").Cells(sirano, 8).Value = TextBox253.Value
Worksheets("veri").Cells(sirano, 9).Value = TextBox254.Value
Worksheets("veri").Cells(sirano, 10).Value = TextBox258.Value
Worksheets("veri").Cells(sirano, 11).Value = TextBox260.Value
Worksheets("veri").Cells(sirano, 12).Value = TextBox261.Value
Worksheets("veri").Cells(sirano, 13).Value = TextBox252.Value

With ListBox1
.ColumnCount = 15
.ColumnWidths = "20;28;93;60;40;60;60;70;45;45;100;30;30;30;30"
.RowSource = "a4:n" & WorksheetFunction.Max(4, Cells(Rows.Count, "a").End(xlUp).Row)
End With
ListBox1.ListIndex = sirano - 4
 
End Sub

Halit bey çok teşekkürler sorun çözüldü. Hayırlı Ramazanlar.
Kod:
    With ActiveCell
        .Offset(0, 2).Value = TextBox3.Value
        .Offset(0, 3).Value = TextBox4.Value
        .Offset(0, 4).Value = TextBox5.Value
        .Offset(0, 5).Value = TextBox259.Value
        .Offset(0, 6).Value = TextBox256.Value
        .Offset(0, 7).Value = TextBox257.Value
        .Offset(0, 8).Value = TextBox253.Value
        .Offset(0, 9).Value = TextBox254.Value
        .Offset(0, 10).Value = TextBox258.Value
        .Offset(0, 11).Value = TextBox260.Value
        .Offset(0, 12).Value = TextBox261.Value
        .Offset(0, 13).Value = TextBox252.Value
    End With

    Application.ScreenUpdating = False
  
    Set ws = Sheets("veri") 'sayfa ismini girin
  
    sonSatir = Application.WorksheetFunction.Max(4, ws.Cells(ws.Rows.Count, "A").End(xlUp).Row)
  
    With ListBox1
        .ColumnCount = 15
        .ColumnWidths = "20;28;93;60;40;60;60;70;45;45;100;30;30;30;30"
        .RowSource = "veri!A4:N" & sonSatir
    End With
    Application.ScreenUpdating = True
Bunu denermisiniz.

CSS:
Private Sub CommandButton4_Click()


'sirano = ListBox1.List(ListBox1.ListIndex, 0) + 3
sirano = ListBox1.ListIndex + 4
ListBox1.RowSource = ""

Worksheets("veri").Cells(sirano, 3).Value = TextBox3.Value
Worksheets("veri").Cells(sirano, 4).Value = TextBox4.Value
Worksheets("veri").Cells(sirano, 5).Value = TextBox5.Value
Worksheets("veri").Cells(sirano, 6).Value = TextBox259.Value
Worksheets("veri").Cells(sirano, 7).Value = TextBox257.Value
Worksheets("veri").Cells(sirano, 8).Value = TextBox253.Value
Worksheets("veri").Cells(sirano, 9).Value = TextBox254.Value
Worksheets("veri").Cells(sirano, 10).Value = TextBox258.Value
Worksheets("veri").Cells(sirano, 11).Value = TextBox260.Value
Worksheets("veri").Cells(sirano, 12).Value = TextBox261.Value
Worksheets("veri").Cells(sirano, 13).Value = TextBox252.Value

With ListBox1
.ColumnCount = 15
.ColumnWidths = "20;28;93;60;40;60;60;70;45;45;100;30;30;30;30"
.RowSource = "a4:n" & WorksheetFunction.Max(4, Cells(Rows.Count, "a").End(xlUp).Row)
End With
ListBox1.ListIndex = sirano - 4
  
End Sub

Teşekkürler Halit bey. Sorun çözüldü. Hayırlı Ramazanlar.
 
Geri
Üst