Macro sans fin

Zepioutas

XLDnaute Nouveau
Bonjour à tous,

Je dois avoir un pb avec la macro suivante que je n'arrive pas à identifier, tout se passe bien jusqu'à la fin mais impossible d'enchaîner :

- Si j'ajoute un "glut" en fin de macro pour vérifier qu'elle s'est correctement finie, le test est négatif (ici exemple = sélectionner A1)
- Si j'apl la macro et que j'en apl une autre successivement, la nouvelle macro s'arrête à la macro "Apl_besoin"

La macro en question :

Sub Apl_Besoin()
'
' Apl_Besoin Macro

'
Application.Goto Reference:="Besoins_Exprimés"
Selection.Copy
Sheets("feuil2").Select
Range("A1").Select
ActiveSheet.Paste

nb = 24
For f = 3 To nb
Columns(2 * f).Insert
Next

Dim Li As Long
Dim i As Byte

i = Range("IV1").End(xlToLeft).Column

For Li = 2 To i

Cells(1, 2 * Li + 1).Select
If Cells(1, 2 * Li + 1) = "" Then
End
End If

If Cells(1, 2 * Li + 1) <> "" Then
Selection.Copy
ActiveCell.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

ActiveCell.Select
ActiveCell.Replace What:="Besoin", Replacement:="Affecté", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False

End If
Next

Range("A1").Select

End Sub

Merci d'avance à tous !
 
Dernière modification par un modérateur:

Zepioutas

XLDnaute Nouveau
Re : Macro sans fin

NB pour info : La macro permet d'insérer une colonne toute les 2 colonnes (1 colonne sur 2) et d'indiquer le titre de la colonne insérée (= le titre de la colonne de gauche avec remplacement de "Besoin" par "Affectation").
 

Zepioutas

XLDnaute Nouveau
Re : Macro sans fin

Bonjour suistrop et autre forum contributor :)

Voici un fichier d'exemple.

Il était trop lourd donc j'ai enlevé les macros, que vous retrouverez si dessous.
La macro qui Call "Apl_Besoin" est "Reporting_projet".

Merci d'avance.

Sub Reporting_projets()

Call Apl_Besoin

Call Apl_Affectations


End Sub



Sub Apl_Besoin()
'
' Apl_Besoin Macro
'
'

'
Range("B86:AE115").Select
Selection.Copy
Sheets("feuil2").Select
Range("A1").Select
ActiveSheet.Paste

nb = 24
For f = 3 To nb
Columns(2 * f).Insert
Next



Dim Li As Long
Dim i As Byte

i = Range("IV1").End(xlToLeft).Column

For Li = 2 To i

Cells(1, 2 * Li + 1).Select
If Cells(1, 2 * Li + 1) = "" Then
End
End If


If Cells(1, 2 * Li + 1) <> "" Then
Selection.Copy
ActiveCell.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

ActiveCell.Select
ActiveCell.Replace What:="Besoin", Replacement:="Affecté", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False

End If
Next

Range("A1").Select


End Sub

Sub Apl_Affectations()

'
' Apl_Besoin Macro
' Macro enregistrée le 04/03/2009 par EDF-GDF

Range("B2").Select


End Sub
 

Pièces jointes

  • Exemple2.xls
    48 KB · Affichages: 51
  • Exemple2.xls
    48 KB · Affichages: 54
  • Exemple2.xls
    48 KB · Affichages: 52
Dernière modification par un modérateur:

suistrop

XLDnaute Impliqué
Re : Macro sans fin

salut, essai avec ca

Code:
Sub Apl_Besoin()
'
' Apl_Besoin Macro
 
'
 
'
Sheets("BDD").Select
Range("B86:AE115").Select
Selection.Copy
Sheets("feuil2").Select
Range("A1").Select
ActiveSheet.Paste
 
nb = 24
For f = 3 To nb
    Columns(2 * f).Insert
Next f
 
 
 
Dim Li As Long
Dim i As Byte
 
i = Range("IV1").End(xlToLeft).Column
 
For Li = 2 To i
 
    Cells(1, 2 * Li + 1).Select
    If Cells(1, 2 * Li + 1) = "" Then
        'on fais rien
    ElseIf Cells(1, 2 * Li + 1) <> "" Then
        Selection.Copy
        ActiveCell.Offset(0, 1).Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
        Application.CutCopyMode = False
 
        ActiveCell.Select
        ActiveCell.Replace What:="Besoin", Replacement:="Affecté", LookAt:=xlPart _
        , SearchOrder:=xlByRows, MatchCase:=False
 
    End If
Next Li
 
Range("A1").Select
 
 
End Sub
tu avais des truc chelou dans ta partie if .... un End qui trainais seul....
 
Dernière modification par un modérateur:

Discussions similaires

Statistiques des forums

Discussions
312 488
Messages
2 088 847
Membres
103 972
dernier inscrit
steeter