SUccession de conditions If - Error d'exécution 13 ( Incompatibilité de type) HELP!!

deb84

XLDnaute Nouveau
Bonjour à tous,

J’ai un problème avec une succession de If :confused:. J’essaie de créer 3 niveaux de condition avec pour chaque niveau une msgbox qui apparait pour que l’utilisateur fasse son choix.
Les conditions se présentent comme suit
Niveau 1 : Choisir la langue ? Français ou néerlandais
Niveau 2 :Voulez-vous-exécuter le calcul du ratio ? Oui ou Annuler
Niveau 3 : Msg box pour confirmer l’option choisie et lancer la macro adéquate
J’ai réussi pour les 2 premiers niveaux mais j’ai une erreur d’exécution ‘13’ – Incompatibilité de type - à mon dernier niveau. Du coup le dernier msgbox n’apparait pas à l’écran. Je n’arrive pas à trouver l’erreur

D’avance un tt grd merci...j'avoue que je suis un peu deseperée alors j'espere que qqun pourra m'aider SVP .
Voici mon code (je joins aussi mon fichier)

Sub TestMsgBoxPerso()
'
' TestMsgBoxPerso Macro
'

'
Dim vRet As Integer
Dim N As Byte
Const T1 As String = "Calcul du ratio - Ratio Berekening ("
Const T2 As String = "/3)"
N = 1
vRet = MsgBoxPerso("Veuillez choisir votre langue - Gelieve uw taal te kiezen", T1 & N & T2, vQuestion, "Français|Nederlands|Annuler/Annuleren", "Book Antiqua", 11, vNormal, vCenter)
If vRet = 1 Then
N = N + 1
vRet = MsgBoxPerso("Vous êtes sur le point de calculer le ratio 'Rapport débiteurs douteux/total débiteurs - 1er trimestre 2010'! Voulez-vous poursuivre?", T1 & N & T2, vExclamation, "Oui|Annuler", "Book Antiqua", 11, vNormal, vCenter)
If vRet = 1 Then
N = N + 1
vRet = MsgBoxPerso("Veuillez patienter lors du calcul du ratio", vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
End If

If vRet = 2 Then
N = N + 1
vRet = MsgBoxPerso("Vous avez décidé d'annuler le calcul du ratio", vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
End If


End If
If vRet = 2 Then
N = N + 1
vRet = MsgBoxPerso("U gaat de ratio 'Verhouding van dubieuze debiteuren t.o.v. de totale debiteuren - bedragen 2010 - Eerste kwartaal' berekenen. Wilt U doorgaan?", T1 & N & T2, vExclamation, "Ja|Annuleren", "Book Antiqua", 11, vNormal, vCenter)
If vRet = 1 Then
N = N + 1
vRet = MsgBoxPerso("Gelieve tijdens de berekening van de ratio te wachten", vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
End If

If vRet = 2 Then
N = N + 1
vRet = MsgBoxPerso("U heeft besloten de berekening van de ratio te annuleren", vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
End If

End If

End Sub
 

Pièces jointes

  • MSgBoxPerso_Test.xlsm
    43.7 KB · Affichages: 56

Lone-wolf

XLDnaute Barbatruc
Re : SUccession de conditions If - Error d'exécution 13 ( Incompatibilité de type) HE

Bonjour deb84 et bienvenue sur XLD :)

peut-être comme ceci ??

Code:
Sub TestMsgBoxPerso()
Dim vRet, N
Const T1 As String = "Calcul du ratio - Ratio Berekening  ("
Const T2 As String = "/3)"

N = 1
vRet = MsgBoxPerso("Veuillez choisir votre langue - Gelieve uw taal te kiezen", T1 & N & T2, vQuestion, "Français|Nederlands|Annuler/Annuleren", "Book Antiqua", 11, vNormal, vCenter)
    
On Error Resume Next
    If vRet = 1 Then
        N = N + 1
        vRet = MsgBoxPerso("Vous êtes sur le point de calculer le ratio 'Rapport débiteurs douteux/total débiteurs - 1er trimestre 2010'! Voulez-vous poursuivre?", T1 & N & T2, vExclamation, "Oui|Annuler", "Book Antiqua", 11, vNormal, vCenter)
                        If vRet = 1 Then
                        N = N + 1
                           vRet = MsgBoxPerso("Veuillez patienter lors du calcul du ratio", vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
                        End If
                        
                        If vRet = 2 Then
                        N = N + 1
                           vRet = MsgBoxPerso("Vous avez décidé d'annuler le calcul du ratio", vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
                        End If
                 
                         
    End If
    If vRet = 2 Then
        N = N + 1
        vRet = MsgBoxPerso("U gaat de ratio 'Verhouding van dubieuze debiteuren t.o.v. de totale debiteuren - bedragen 2010 - Eerste kwartaal' berekenen. Wilt U doorgaan?", T1 & N & T2, vExclamation, "Ja|Annuleren", "Book Antiqua", 11, vNormal, vCenter)
                         If vRet = 1 Then
                         N = N + 1
                         vRet = MsgBoxPerso("Gelieve tijdens de berekening van de ratio te wachten", vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
                         End If
                         
                         If vRet = 2 Then
                         N = N + 1
                         vRet = MsgBoxPerso("U heeft besloten de berekening van de ratio te annuleren", vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
                         End If

    End If

End Sub


A bientôt :cool:
 

Lone-wolf

XLDnaute Barbatruc
Re : SUccession de conditions If - Error d'exécution 13 ( Incompatibilité de type) HE

Bonsoir deb84,

voici un petit exemple

Code:
Public Const capt = "AIDE"
Public Const ligne = "Si vous avez besoin d'aide cliquez sur Oui"
Public Const lig = "Ah bon?! Pourquoi vous m'appelez alors??!"      ' Si Non est cliqué
Public msg As String

Sub test()
msg = MsgBox(ligne, vbYesNo, capt)
With Sheets(1)
.Range("c5").Value = "J'arrive !"
If msg = vbNo Then: msg = MsgBox(lig, vbOKCancel, capt): .Range("e5").Value = "Et bein tampis !"
End With
End Sub


A bientôt :cool:
 

Lone-wolf

XLDnaute Barbatruc
Re : SUccession de conditions If - Error d'exécution 13 ( Incompatibilité de type) HE

Bonjour deb...enfin si tu passe par ici

Bonjour Didier (MyDearFreinds)

Voici le code corrigé et à inserer dans un module standard et non dans une feuile.

Code:
Sub BDD()
Dim vRet As Integer
Dim N As Byte
Const T1 As String = "Calcul du ratio - Ratio Berekening  ("
Const T2 As String = "/3)"
    N = 1
    vRet = MsgBoxPerso("Veuillez choisir votre langue - Gelieve uw taal te kiezen", T1 & N & T2, vQuestion, "Français|Nederlands|Annuler/Annuleren", "Book Antiqua", 11, vNormal, vCenter)
    If vRet = 1 Then
    N = N + 1
    vRet = MsgBoxPerso("Vous êtes sur le point de calculer le ratio 'Rapport débiteurs douteux/total débiteurs - 1er trimestre 2010'! Voulez-vous poursuivre?", T1 & N & T2, vExclamation, "Oui|Annuler", "Book Antiqua", 11, vNormal, vCenter)
    
    If vRet = 1 Then
    N = N + 1
    vRet = MsgBoxPerso("Veuillez patienter lors du calcul du ratio", T1 & N & T2, vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
    End If
    
    If vRet = 2 Then
    N = N + 1
    vRet = MsgBoxPerso("Vous avez décidé d'annuler le calcul du ratio", T1 & N & T2, vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
    End If
    End If
    
    If vRet = 2 Then
    N = N + 1
    vRet = MsgBoxPerso("U gaat de ratio 'Verhouding van dubieuze debiteuren t.o.v. de totale debiteuren - bedragen 2010 - Eerste kwartaal' berekenen. Wilt U doorgaan?", T1 & N & T2, vExclamation, "Ja|Annuleren", "Book Antiqua", 11, vNormal, vCenter)
       
    If vRet = 1 Then
    N = N + 1
    vRet = MsgBoxPerso("Gelieve tijdens de berekening van de ratio te wachten", T1 & N & T2, vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
    End If
    
    If vRet = 2 Then
    N = N + 1
    vRet = MsgBoxPerso("U heeft besloten de berekening van de ratio te annuleren", T1 & N & T2, vInformation, "Ok", "Book Antiqua", 11, vNormal, vCenter)
    End If
    End If
End Sub

A bientôt peut-être :cool:
 

deb84

XLDnaute Nouveau
Re : SUccession de conditions If - Error d'exécution 13 ( Incompatibilité de type) HE

Allelujah, ça marche!!!!!!

Evidemment que je passe par ici.... :) Je cherchais deseperemment une solution à mon probleme..J'ai vu ta réponse hier, mais je devais faire mes corrections sur le fichier au boulot... En tout cas, Lone-Wolf, un super géant mega merci. Maintenant que j'ai vu mon erreur, je trouve ca tout bête....

Merci pour ton temps. C'est mon chef qui va être content.

Une bonne journée et un super weekend

A la prochaine peut-etre...:p
 

Statistiques des forums

Discussions
312 231
Messages
2 086 441
Membres
103 210
dernier inscrit
Bay onais