Ma syntaxe pour lancement de macros n'est pas bonne...

Christian0258

XLDnaute Accro
Re, bonjour à tout le forum,

J'ai 4 macros qui fonctionnent parfaitement.
Je souhaiterais lancer 3 macros si en J4 =2 et 3 macros si en J4 = 1
j'ai fait ça...mais ça plante, quelle est la bonne syntaxe ?

Sub Archiver_Pdf_Raz()
If Range("J4").Value = 2 Then
Call OptimiseTempsExecArchivlign15
Else
Call EnregDevisFormulaire_Pdf
Else
Call RAZ
End If

If Range("J4").Value = 1 Then
Call OptimiseTempsExecArchivlign15
Else
Call EnregFactures_Pdf
Else
Call RAZ
End If

End Sub

Merci pour votre aide.
Christian
 

Dranreb

XLDnaute Barbatruc
Bonjour.
Dans la bonne syntaxe d'un bloc If il ne peut y avoir qu'un sous bloc Else en dernier avant le End If
Mais avant lui il peut y avoir après le bloc If condition1 Then plusieurs sous blocs ElseIf conditionx Then
Dans votre cas il vaudrait mieux Select Case Range("J4").Value
Case 1: OptimiseTempsExecArchivlign15: EnregDevisFormulaire_Pd
Case 2: OptimiseTempsExecArchivlign15: EnregFactures_Pdf
Case Else: RAZ: End Select
 

Paf

XLDnaute Barbatruc
Bonjour à tous

ou bien en gardant la structure initiale

Code:
Sub Archiver_Pdf_Raz()
 Call OptimiseTempsExecArchivlign15
If Range("J4").Value = 2 Then
    Call EnregDevisFormulaire_Pdf
    Call RAZ
End If
If Range("J4").Value = 1 Then
    Call EnregFactures_Pdf
   Call RAZ
End If
End Sub

Nb: avec ou sans Call

A+
 

Discussions similaires

Statistiques des forums

Discussions
312 084
Messages
2 085 192
Membres
102 809
dernier inscrit
Sandrine83