Trier une colonne Excel via VB.NET

cs_Caussenard Messages postés 28 Date d'inscription vendredi 16 juillet 2004 Statut Membre Dernière intervention 8 juillet 2008 - 30 juin 2005 à 09:07
cs_Caussenard Messages postés 28 Date d'inscription vendredi 16 juillet 2004 Statut Membre Dernière intervention 8 juillet 2008 - 4 juil. 2005 à 09:07
Bonjour à tous,

Je viens juste de passer en VB.NET et je cherche à utiliser la fonction
tri de excel à travers mon programme mais VB me souligne "Range,
xlAscending, xlGuess, xlTopToBottom ect..." J'ai vu sur le forum qu'il
était possible d'utiliser cette fonction pouvez vous me dire ce qui ne
vas pas dans mon programme afin que celui-ci marche.



Merci d'avance

Caussenard



Private Sub DeterminationLotsLocalisations_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DeterminationLotsLocalisations.Click



Dim SylphApp As Object

Dim SylphWkbMachine As Object

Dim SylphWksMachine As Object

Dim FileName As String

Dim PRISE As String

Dim Ligne As String

Ligne = 1



'Ouverture du fichier MACHINE

SylphApp = CreateObject("Excel.Application")

SylphApp.DisplayAlerts = False

SylphApp.EnableEvents = False

SylphApp.Visible = True

FileName = CF.GetCAProjet & "FM_" & CF.NomProjet & ".xls"

SylphWkbMachine = SylphApp.Workbooks.Open(FileName)

SylphWksMachine = SylphWkbMachine.sheets("Feuil1")



'Suppression des colonnes inutiles

SylphWksMachine.Columns("B:H").Delete()

SylphWksMachine.Columns("C:BE").Delete()



Ect.........



'Classement des Prises par leur noms



SylphWksMachine.Range("A2:B5000").Sort(Key1: = ("A2"), Order1:=xlAscending Range _

("B2"), Order2: =xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _

:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _

DataOption2:=xlSortNormal)



'Enregistrement du fichier Machine

FileName = CF.GetCALoc & "Loc" & CF.NomProjet & ".xls"

SylphWkbMachine.Saveas(FileName)

SylphWkbMachine.Close(False)

SylphApp.quit()



End Sub
Caussenard

3 réponses

voilhes Messages postés 33 Date d'inscription lundi 20 janvier 2003 Statut Membre Dernière intervention 6 septembre 2006 6
1 juil. 2005 à 10:25
Tu peux essayer ça:

SylphWksMachine.Range("A2:B5000").Sort(Key1:= ("A2"), Order1:=xlAscending SylphWksMachine. Range _
("B2"), Order2: =xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal)

-Francis-
0
cs_Caussenard Messages postés 28 Date d'inscription vendredi 16 juillet 2004 Statut Membre Dernière intervention 8 juillet 2008 1
4 juil. 2005 à 08:43
Merci beaucoup effectivement si je rajoute le nom de la sheet devant chaque instruction ça marche.



SylphWksMachine.Range("A2:B5000").Sort(Key1:SylphWksMachine .Range("A2"), Order1:SylphWksMachine.xlAscending, Key2:= SylphWksMachine .Range _

("B2"), Order2: =SylphWksMachine.xlAscending, Header:= SylphWksMachine .xlGuess, OrderCustom: =1, MatchCase _

:= False, Orientation:= SylphWksMachine .xlTopToBottom, DataOption1: =SylphWksMachine.xlSortNormal, _

DataOption2:=SylphWksMachine.xlSortNormal)

Caussenard
0
cs_Caussenard Messages postés 28 Date d'inscription vendredi 16 juillet 2004 Statut Membre Dernière intervention 8 juillet 2008 1
4 juil. 2005 à 09:07
Désolé je retire ce que j'ai dit ça me supprime les erreurs mais ça ne fait pas marcher le programme pour autant.

Caussenard
0
Rejoignez-nous