2017-06-22 1 views
1

Ich möchte den VBA-Code fragen, den ich unten erstellt habe. Nach dem Test ändert sich der Blattwert nicht mehr. Wie behebe ich diesen Code, damit der Wert, den ich eingegeben habe, im Blatt aktualisiert werden kann?Warum ändert diese vba Formel den Wert des Blattes nicht?

Private Sub cmdupdate_click() 
Application.ScreenUpdating = False 
Dim noM As Integer 
'warning 
    If txtName.Value = "" Then 
     MsgBox "Insert Name.", vbExclamation 
     txtName.SetFocus 
     Exit Sub 
    End If 

If Me.cmbslno.Value = "" Then 
MsgBox "No Number!!!", vbExclamation, "Number" 
Exit Sub 
End If 
noM = Me.cmbslno.Value 
Sheets("data").Select 
Dim bre As Double 
Dim msg As String 
Dim org As String 
bre = Me.cmbslno.Value 
bre = bre + 1 
Rows(bre).Select 
Cells(bre, 2) = Me.txtName.Value 
Cells(bre, 3) = Me.txtPanggilan.Value 
Cells(bre, 4) = Me.txtNis.Value 
Cells(bre, 5) = Me.txtNisn.Value 
Cells(bre, 6) = Me.txtTtl.Value 
Cells(bre, 7) = Me.CmbJk.Value 
Cells(bre, 8) = Me.CmbAgama.Value 
Cells(bre, 9) = Me.txtSAwal.Value 
Cells(bre, 10) = Me.txtASiswa.Value 
Cells(bre, 11) = Me.txtAyah.Value 
Cells(bre, 12) = Me.txtIbu.Value 
Cells(bre, 13) = Me.txtPAyah.Value 
Cells(bre, 14) = Me.txtPIbu.Value 
Cells(bre, 15) = Me.txtJln.Value 
Cells(bre, 16) = Me.txtDesa.Value 
Cells(bre, 17) = Me.txtKec.Value 
Cells(bre, 18) = Me.txtKab.Value 
Cells(bre, 19) = Me.txtPro.Value 
Cells(bre, 20) = Me.txtHp.Value 
Cells(bre, 21) = Me.txtWali.Value 
Cells(bre, 22) = Me.txtPWali.Value 
Cells(bre, 23) = Me.txtAWali.Value 
Cells(bre, 36) = Me.txtFoto.Value 
bre = bre - 1 
msg = "Number " & bre & ". For " & txtName.Value & " Updating . Continue?" 
Unload Me 
org = MsgBox(msg, vbYesNo, "Confirm") 
If org = vbYes Then 
Me.FormData.Show 
Else 
Sheets("Data").Select 
End If 
Application.ScreenUpdating = True 
End Sub 

Vielen Dank, hoffen, dass es Ihre aktualisierten Code

+0

Können Sie Ihren Code bitte einrücken. – litelite

+0

Hast du einen Haltepunkt eingebaut, um zu testen, ob er tatsächlich läuft? – litelite

Antwort

0

Bitte sehen aufgelöst werden kann. Ich denke, das Problem war in .Value Eigenschaft in Zelle Wert Zuordnung Anweisungen fehlen. Ich korrigierte auch einige andere kleinere Probleme, siehe die Kommentare.

Private Sub cmdupdate_click() 

    'warning 
    If Me.txtName.Value = "" Then 
     MsgBox "Please insert name.", vbExclamation 
     Me.txtName.SetFocus 'added Me for consistency 
     Exit Sub 
    End If 

    If Me.cmbslno.Value = "" Then 
     MsgBox "Please enter number.", vbExclamation 'stopped yelling at the user 
     Me.cmbslno.SetFocus ' added - the same behaviour as previous one 
     Exit Sub 
    End If 

    Application.ScreenUpdating = False 'moved here, otherwise above Exit Sub keeps False 
    Dim noM As Integer 'moved from top, we don't need it earlier 
    noM = Val(Me.cmbslno.Value) 
    Sheets("data").Select 
    Dim bre As Integer ' changed from Double to Integer 
    Dim msg As String 
    Dim org As String 
    bre = Me.cmbslno.Value 
    bre = noM + 1 
    Rows(bre).Select 
    Cells(bre, 2).Value = Me.txtName.Value 
    Cells(bre, 3).Value = Me.txtPanggilan.Value 
    Cells(bre, 4).Value = Me.txtNis.Value 
    Cells(bre, 5).Value = Me.txtNisn.Value 
    Cells(bre, 6).Value = Me.txtTtl.Value 
    Cells(bre, 7).Value = Me.CmbJk.Value 
    Cells(bre, 8).Value = Me.CmbAgama.Value 
    Cells(bre, 9).Value = Me.txtSAwal.Value 
    Cells(bre, 10).Value = Me.txtASiswa.Value 
    Cells(bre, 11).Value = Me.txtAyah.Value 
    Cells(bre, 12).Value = Me.txtIbu.Value 
    Cells(bre, 13).Value = Me.txtPAyah.Value 
    Cells(bre, 14).Value = Me.txtPIbu.Value 
    Cells(bre, 15).Value = Me.txtJln.Value 
    Cells(bre, 16).Value = Me.txtDesa.Value 
    Cells(bre, 17).Value = Me.txtKec.Value 
    Cells(bre, 18).Value = Me.txtKab.Value 
    Cells(bre, 19).Value = Me.txtPro.Value 
    Cells(bre, 20).Value = Me.txtHp.Value 
    Cells(bre, 21).Value = Me.txtWali.Value 
    Cells(bre, 22).Value = Me.txtPWali.Value 
    Cells(bre, 23).Value = Me.txtAWali.Value 
    Cells(bre, 36).Value = Me.txtFoto.Value 

    msg = "Number " & noM & ". For " & txtName.Value & " Updating. Continue?" 
    Unload Me 
    org = MsgBox(msg, vbYesNo, "Confirm") 
    If org = vbYes Then 
     Me.FormData.Show 
    Else 
     Sheets("Data").Select 
    End If 
    Application.ScreenUpdating = True 
End Sub 
+0

Danke miroxlav ... –

Verwandte Themen