OVH Cloud OVH Cloud

macro : incompatibilité de type

1 réponse
Avatar
Patrick BASTARD
Bonjour à toutes et tous.

Qui pourrait me dire pourquoi ce code me renvoie "incompatibilité de type"
quand je saisis par erreur une lettre, ou rien, et comment corriger ?

D'avance, Merci.

Dim NbSal
Dim n As Byte

NbSal = InputBox( "Entrez un nombre entre 1 et 10", "SACA -
Administration : Nombre à créer")
Application.ScreenUpdating = False
'Si l'usager annule l'opération
If NbSal < 1 And NbSal > 10 And NbSal = "" Then Exit Sub
For n = 1 To NbSal
Range("A:C").Copy
Application.Goto Reference:="Décaler"
ActiveCell.Offset(0, -3).Insert Shift:=xlToRight
Calculate
Next
Application.ScreenUpdating = True
MsgBox "C'est fait!", , "SACA - Création de fiches salarié"

End Sub

--
Bien amicordialement,
P. Bastard

1 réponse

Avatar
Patrick BASTARD
Bonjour, *Alain*

Et merci.

Ces lignes sont bien celles qu'il me fallait.
;-)

Une modif possible pour tester l'imputBox :

If Not IsNumeric(NbSal) Or NbSal = "" Then Exit Sub
If NbSal < 1 Or NbSal * 1 > 10 Then Exit Sub

AV


--
Bien amicordialement,
P. Bastard