MsgBox apparaît plusieurs fois après que datatables ont été extraites d'une feuille

J'aimerais get de l'aide avec le code suivant. Je suis très nouveau à ce sujet, mais je pense que c'est une solution facile. Je ne peux pas adapter les suggestions d'autres searchs dans mon code.

Les msgboxes fonctionnent bien sur la première passe pour vérifier si les valeurs de la textbox sont correctes, mais lorsque je vérifie si un résultat de la formule d'une feuille est correct, je reçois 5 boîtes de message.

J'espère que cela a du sens, laissez-moi savoir si vous avez des suggestions!

`Private Sub SpeedCommand_Click() Dim ctl As Control If TextBox1AM180.Value > 12000 And TextBox1AM180.Value <> "" Then MsgBox "Rate Value is out of range for this boom. Ensure rate value is less than 12,000 lbs./acre", vbExclamation, "Main Bin Application Rate" Me.TextBox1AM180.SetFocus Exit Sub End If If (TextBox2AM180.Value > 120 Or TextBox2AM180.Value < 20) And TextBox2AM180.Value <> "" Then MsgBox "Density Value is out of range. Ensure density value is between 20 and 120 lbs./cu ft.", vbExclamation, "Main Bin Density" Me.TextBox2AM180.SetFocus Exit Sub End If If TextBox3AM180.Value > 12000 And TextBox3AM180.Value <> "" Then MsgBox "Rate Value is out of range for this boom. Ensure rate value is less than 12,000 lbs./acre", vbExclamation, "Granular Bin Application Rate" Me.TextBox3AM180.SetFocus Exit Sub End If If (TextBox4AM180.Value > 120 Or TextBox4AM180.Value < 20) And TextBox4AM180.Value <> "" Then MsgBox "Density Value is out of range. Ensure density value is between 20 and 120 lbs./cu ft.", vbExclamation, "Granular Bin Density" Me.TextBox4AM180.SetFocus Exit Sub End If ' Write data to worksheet With Range("B4") .Offset(0, 0).Value = Me.TextBox1AM180.Value .Offset(1, 0).Value = Me.TextBox2AM180.Value .Offset(5, 0).Value = Me.TextBox3AM180.Value .Offset(6, 0).Value = Me.TextBox4AM180.Value End With If Range("MaxSpeed1").Value > 30 Then MsgBox "Based upon rate and density, speed is ressortingcted by machine top end application speed." Exit Sub End If If Range("MaxSpeed2").Value > 30 Then MsgBox "Based upon rate and density, speed is ressortingcted by machine top end application speed." Exit Sub End If ' Hide the form frmAirmax.Hide 

Utilisez la propriété Application.EnableEvents pour désactiver temporairement les events du tir, puis réactivez-les lorsque vous avez terminé.

Quelque chose comme ça:

 Application.EnableEvents = False With Range("B4") .Offset(0, 0).Value = Me.TextBox1AM180.Value .Offset(1, 0).Value = Me.TextBox2AM180.Value .Offset(5, 0).Value = Me.TextBox3AM180.Value .Offset(6, 0).Value = Me.TextBox4AM180.Value End With Application.EnableEvents = True