IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

type en vba excel ?


Sujet :

Macros et VBA Excel

  1. #1
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 664
    Points
    66 664
    Billets dans le blog
    1
    Par défaut type en vba excel ?
    j'essaye de stocker des éléments dans un array de types ...
    mais il ne me reconnait même pas au départ le type ...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
     
     
    Public Type rapportline
     cle As Integer
     ORDNO As Integer
     FOLERNO As Integer
     Testcode As Integer
     METAL As String * 6
     FINAL  As String * 6
    End Type
     
    Private Sub rapport()
    Dim NbrLignes As Integer
     
    MsgBox rapportline.cle
     Dim RapportLines()
     
     
    Sheets("feuil3").Select
        Range("A1").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Sort Key1:=Range("F2"), Order1:=xlAscending, Key2:=Range("J2") _
            , Order2:=xlAscending, Key3:=Range("K2"), Order3:=xlAscending, Header:= _
            xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
     
     
     
     
    Range("A2").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
     
     NbrLignes = Selection.Rows.Count
     For i = 0 To NbrLignes
        ReDim Preserve RapportLines(i + 1)
        rapportline.cle = Sheets("feuil3").Range("F1").Offset(0, i + 1).Value
        rapportline.ORDNO = Sheets("feuil3").Range("J1").Offset(0, i + 1).Value
        rapportline.FOLDERNO = Sheets("feuil3").Range("K1").Offset(0, i + 1).Value
        rapportline.Testcode = Sheets("feuil3").Range("L1").Offset(0, i + 1).Value
        rapportline.METAL = Sheets("feuil3").Range("M1").Offset(0, i + 1).Value
        rapportline.FINAL = Sheets("feuil3").Range("M1").Offset(0, i + 1).Value
        RapportLines(i) = rapportline
     Next
     
    End Sub
    il me reclame un objet rapportline ???

  2. #2
    Expert éminent sénior


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Points : 20 040
    Points
    20 040
    Par défaut
    déjà tu ne peu pas utiliser un type comme cela :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    MsgBox rapportline.cle
    il faut à la limite créer une variable du dit type et alors tu peu afficher la donnée (mais bon je coris pas que ce soit ce que tu ve faire..)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
     Dim MonRapport as rapportline
     Mon Rapport.cle = 1
    MsgBox MonRapport.cle

    pour la déclaration de ton tableau utilise
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
     Dim RapportLines()

    que ve tu faire avec cette ligne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
     RapportLines(i) = rapportline

  3. #3
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 664
    Points
    66 664
    Billets dans le blog
    1
    Par défaut
    arf oui je crois que j'ai skippé la variable ...
    je teste !

  4. #4
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 664
    Points
    66 664
    Billets dans le blog
    1
    Par défaut
    Merci bbil!
    c'était bien ça ...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
     
     
    Public Type RLine
     cle As String
     ORDNO As String
     FOLDERNO As String
     Testcode As String
     METAL As String * 6
     FINAL  As String * 6
    End Type
     
    Private Sub rapport()
    Dim NbrLignes As Integer
    Dim RapportLine As RLine
     
     Dim RapportLines() As RLine
     
     
     
    Sheets("feuil3").Select
        Range("A1").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Sort Key1:=Range("F2"), Order1:=xlAscending, Key2:=Range("J2") _
            , Order2:=xlAscending, Key3:=Range("K2"), Order3:=xlAscending, Header:= _
            xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
     
     
     
     
    Range("A2").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
     
     NbrLignes = Selection.Rows.Count
     For i = 0 To NbrLignes
        ReDim Preserve RapportLines(i + 1)
        RapportLine.cle = Sheets("Feuil3").Range("F1").Offset(i + 1, 0).Value
        RapportLine.ORDNO = Sheets("Feuil3").Range("J1").Offset(i + 1, 0).Value
        RapportLine.FOLDERNO = Sheets("Feuil3").Range("K1").Offset(i + 1, 0).Value
        RapportLine.Testcode = Sheets("Feuil3").Range("L1").Offset(i + 1, 0).Value
        RapportLine.METAL = Sheets("Feuil3").Range("M1").Offset(i + 1, 0).Value
        RapportLine.FINAL = Sheets("Feuil3").Range("M1").Offset(i + 1, 0).Value
        RapportLines(i) = RapportLine
     Next
     
    End Sub

  5. #5
    Expert éminent sénior


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Points : 20 040
    Points
    20 040
    Par défaut
    à oui j'avais pas vu cette variable intermédiaire ... en fait elle n'est pas trop utile ... tu aurai pu écrire :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
      RapportLines(i).cle = Sheets("Feuil3").Range("F1").Offset(i + 1, 0).Value
    ....

  6. #6
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 664
    Points
    66 664
    Billets dans le blog
    1
    Par défaut
    oui joli raccourci mais je trouve cela moins explicite ...
    en fait dans l'idée de mon code je construis un tableau de lignes ...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
     
     
    Public Type RLine
     cle As String
     ORDNO As String
     FOLDERNO As String
     Testcode As String
     METAL As String * 6
     FINAL  As String * 6
    End Type
     
    Private Sub rapport()
    Dim NbrLignes As Integer
    Dim RapportLine As RLine
     
     Dim RapportLines() As RLine
     
     
     
    Sheets("feuil3").Select
        Range("A1").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Sort Key1:=Range("F2"), Order1:=xlAscending, Key2:=Range("J2") _
            , Order2:=xlAscending, Key3:=Range("K2"), Order3:=xlAscending, Header:= _
            xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
     
     
     
     
    Range("A2").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
     
     NbrLignes = Selection.Rows.Count
     For i = 0 To NbrLignes
        ReDim Preserve RapportLines(i + 1)
        RapportLine.cle = Sheets("Feuil3").Range("F1").Offset(i + 1, 0).Value
        RapportLine.ORDNO = Sheets("Feuil3").Range("J1").Offset(i + 1, 0).Value
        RapportLine.FOLDERNO = Sheets("Feuil3").Range("K1").Offset(i + 1, 0).Value
        RapportLine.Testcode = Sheets("Feuil3").Range("L1").Offset(i + 1, 0).Value
        RapportLine.METAL = Sheets("Feuil3").Range("M1").Offset(i + 1, 0).Value
        RapportLine.FINAL = Sheets("Feuil3").Range("M1").Offset(i + 1, 0).Value
        RapportLines(i) = RapportLine
     Next
     
     
     
    Dim Analyse As String
    Dim TabAnalyse
     
    Entete = "cle,ORDNO,FOLDERNO,TESTCODE,Al,B,Ca,Cl-,Co,Cr,Cu,Fe,Four,Hf,Mg,Mn,Mo,N,Ni,O,P,Si,Ti,V"
    TabENTETE = Split(Entete, ",")
     
    For i = 0 To UBound(TabENTETE)
        Sheets("Feuil1").Range("A1").Offset(0, i).Value = TabENTETE(i)
    Next
     
    For i = 1 To UBound(RapportLines)
         Sheets("Feuil1").Range("A1").Offset(i + 1, 0).Value = RapportLines(i).cle
         Sheets("Feuil1").Range("B1").Offset(i + 1, 0).Value = RapportLines(i).ORDNO
         Sheets("Feuil1").Range("C1").Offset(i + 1, 0).Value = RapportLines(i).FOLDERNO
         Sheets("Feuil1").Range("D1").Offset(i + 1, 0).Value = RapportLines(i).Testcode
         For j = 0 To 19
          If RapportLines(i).METAL = Sheets("Feuil1").Range("E1").Offset(0, j).Value Then
              Sheets("Feuil1").Range("E1").Offset(i + 1, j).Value = RapportLines(i).FINAL
          End If
         Next j
      Next i
     
     
     Sheets("feuil1").range("A1").select
      Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
     Selection.Columns.AutoFit
     
     End Sub

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [VBA Excel] Liste chainée de type perso
    Par Danos dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 03/04/2008, 15h13
  2. VBA-Excel-Inputbox-type 8-Message 424
    Par rayvsdenver dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 15/08/2007, 10h43
  3. [VBA Excel] Un tableau dynamique dans un type utilisateur?
    Par cyber_N dans le forum Macros et VBA Excel
    Réponses: 7
    Dernier message: 23/07/2006, 19h51
  4. VBA Excel, modifier une lettre type dans word
    Par morgan47 dans le forum VBA Word
    Réponses: 2
    Dernier message: 26/06/2006, 21h02
  5. [VBA Excel]collection et type
    Par Tan dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 25/02/2005, 18h22

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo