VBA - Code qui fonctionne mais qui fait planter Excel lorsque je sauvegarde

lowkick

XLDnaute Nouveau
Bonjour à tous,
Je vous sollicite a nouveau car j'ai un souci sur un bout de code qui me fait crasher excel lorsque j'essaye de sauvegarder . Par ailleurs ce code fonctionne très bien ...
J'ai fait plein de tests mais je soupçonne une erreur de syntaxe.
Est ce que quelqu'un aurais la gentillesse d'y jeter un oeil ?


Code:
Private Sub triart()
Dim ColRng As Range
Dim Col As Range
Dim maPlage As Range

Set g = Sheets("PRO-Ouvr-Ind")
c2 = Application.CountIf(g.[a:a], labelrefOuvr.Caption)

With g

Set c1 = .Range("a:a").Find(labelrefOuvr.Caption, LookIn:=xlValues, LookAt:=xlWhole)

premLigne = c1.Row + 1
DernLigne = premLigne + c2 - 2

Set maPlage = Range("A" & premLigne & ":F" & DernLigne)
Set oRangeKey = maPlage.Cells(0, 2)


ReDim lstord(1 To c2 - 1)
c = 0
For j = 0 To listart.ListCount - 1
    c = c + 1
    lstord(c) = "" & listart.List(j) & ""
Next j
c2 = 0

Application.AddCustomList ListArray:=lstord

' Tri selon cutomlist

g.Sort.SortFields.Clear
maplage.Sort Key1:=oRangeKey, Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=Application.CustomListCount + 1, MatchCase:=False, _
    Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

' clean up
Application.deletecustomlist Application.CustomListCount

End With

Erase lstord

End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 199
Messages
2 086 161
Membres
103 148
dernier inscrit
lulu56