完成注册后,我在UserForm中具有用于注册会计操作的宏,然后单击Userform中的“ x”按钮,我的excel工作簿就关闭了,而没有询问我。我知道这段代码是问题所在,因为我的用户窗体做了其他事情,而这些其他事情都不会导致此问题。
Confirmar = MsgBox("¿Desea registrar la nueva operación contable?", vbYesNo)
If Confirmar = vbYes Then
Next_LibroDiario = WShe_LibroDiario.Cells(Rows.Count, 2).End(xlUp).Row + 1
If APP_RegistroContable.OptionButton_Débito = True Then
WShe_LibroDiario.Cells(Next_LibroDiario, 7) = APP_RegistroContable.Monto + 0
APP_RegistroContable.Monto = ""
ElseIf APP_RegistroContable.OptionButton_Crédito = True Then
WShe_LibroDiario.Cells(Next_LibroDiario, 8) = APP_RegistroContable.Monto + 0
APP_RegistroContable.Monto = ""
ElseIf APP_RegistroContable.OptionButton_Débito = False _
And APP_RegistroContable.OptionButton_Crédito = False _
Then
MsgBox "Please select an accounting item"
Exit Sub
End If
WShe_LibroDiario.Cells(Next_LibroDiario, 2) = APP_RegistroContable.Ctas_Bancarias
APP_RegistroContable.Ctas_Bancarias = ""
WShe_LibroDiario.Cells(Next_LibroDiario, 3) = CDate(APP_RegistroContable.Fecha)
APP_RegistroContable.Fecha = ""
WShe_LibroDiario.Cells(Next_LibroDiario, 4) = APP_RegistroContable.Recibo_CF
APP_RegistroContable.Recibo_CF = ""
WShe_LibroDiario.Cells(Next_LibroDiario, 5) = APP_RegistroContable.Nombre
APP_RegistroContable.Nombre = ""
WShe_LibroDiario.Cells(Next_LibroDiario, 6) = APP_RegistroContable.Auxiliar + 0
WShe_LibroDiario.Cells(Next_LibroDiario, 9) = APP_RegistroContable.Clasificación
APP_RegistroContable.Clasificación = ""
WShe_LibroDiario.Cells(Next_LibroDiario, 10) = APP_RegistroContable.Comentario
APP_RegistroContable.Comentario = ""
'这部分使用注册的日期和编号创建会计操作的ID。 在该日期注册的操作
Last_ID = WShe_LibroDiario.Cells(Rows.Count, 2).End(xlUp).Row
Set Rang_Fecha = WShe_LibroDiario.Range("C8:C" & Last_ID)
Set Rang_ID = WShe_LibroDiario.Cells(Last_ID, 3)
Inte_IDGenerator = WorksheetFunction.CountIf(Rang_Fecha, Rang_ID)
WShe_LibroDiario.Cells(Last_ID, 1).Value = WShe_LibroDiario.Cells(Last_ID, 3).Value & "-0" & _
Inte_IDGenerator
MsgBox "The accounting operation is now in the system"
End if