Hi,
Please see my code below. It works fine when running.
Hope someone can help, I'm still a newbie with VBA.
1. Every time I close my workbook, I get the message: "Code execution has been interrupted". Why?
2. Can my code be written smarter/shorter?
Best Regards
Skovgaard
Please see my code below. It works fine when running.
Hope someone can help, I'm still a newbie with VBA.
1. Every time I close my workbook, I get the message: "Code execution has been interrupted". Why?
2. Can my code be written smarter/shorter?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Range("N30").Value = 0 Then Exit Sub
If Not Intersect(Target, Range("D8:D9")) Is Nothing Then
If Target.Value = "" Then
MsgBox "Projektnavn og VVS'er skal være udfyldt, hvis projektrabat gives." & vbNewLine & vbNewLine & "Sæt projektrabat = 0%, for at slette feltet"
Application.Undo
End If
End If
If Not Intersect(Target, Range("E14:L27")) Is Nothing Then
If Range("O28").Value < Range("N8").Value And Range("E28").Value < Range("N9").Value Then
MsgBox "Kriterie for projektrabat ikke opfyldt." & vbNewLine & vbNewLine & "Sæt projektrabat = 0%, for at ændre feltet"
Application.Undo
End If
End If
If Not Intersect(Target, Range("E14:L27")) Is Nothing Then
If Range("AI28").Value < 0.3 And Range("N30").Value > 0 Then
MsgBox "Kriterie for projektrabat ikke opfyldt." & vbNewLine & vbNewLine & "Sæt projektrabat = 0%, for at ændre feltet"
Application.Undo
End If
End If
If Not Intersect(Target, Range("E14:L27")) Is Nothing Then
If Range("AI28").Value <= 0.4 And Range("N30").Value > 0.05 Then
MsgBox "Kriterie for projektrabat ikke opfyldt." & vbNewLine & vbNewLine & "Sæt projektrabat = 0%, for at ændre feltet"
Application.Undo
End If
End If
End Sub
Best Regards
Skovgaard