Réalisation d'une macro

esterline.romuald

XLDnaute Nouveau
Bonjour à tous

Je suis assistant dans un service du personnel, je metrise les base d'excel pour pas les macros, chaque semaine je dois rentrer les heures des employé dans un logiciel, pour se faire se dois faire un fichier csv d'un fichier Excel mais je dois faire quelques manipulations manuellement sur le fichier

Est-il possible de faire une macro qui ferai tous en une seul fois, c'est juste pour gagner du temps

Voici la liste des choses que je fais

1. SUPPRESSION COLONNE E
2. CODE 30 ET 1 ET 2 : SUPPRIMER LES LIGNE
3. COLONNE F : CODE 11 : ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4 SAUF SI CTVAR 5 = 0
4. COLONNE F : CODE 43 : VSD : CTVAR 5 : 2,33 CTVAR92 : 6
5. COLONNE F : CODE 44 et 45 : CTVAR 5 : 3 CTVAR92 : 8
6. COLONNE F : CODE 61 : CTVAR 5 = 6,66
7. COLONNE F : CODE 63 : CTVAR 5 = 6,66
8. COLONNE F : CODE 64 NUIT : CTVAR 5 = 0,33 CTVAR92 : 7,75
9. COLONNE F : CODE 65 NUIT : CTVAR 5 = 3,50 CTVAR92 : 3,42
10.COLONNE F : NUMODJO : CODE 10 : ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4 SAUF SI CTVAR 5 = 0
11.FILTRE COLONNE CDACT : SI DES AI METTRE O DS CTVAR5
12.SI COLONNE CDACT = FERI ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4
13.SI COLONNE CDACT = HS SUR LE SAMEDI ON MET 0
14.SI HS JOUR DE LA SEMAINE ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4
15.SI PERSONNE MAL OU MAL 3 METTRE O DS CTVAR5
16.SI PERSONNE MIS : ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4
17.SUPPRIMER COLONNE APRES CTVAR 92
18.COLONNE CTVAR 92 : Si 1 mettre 0
19.Remplacer virgule par point
20.supprimer ligne d entete
21.enregistrer format csv

Je vous joint un fichier exemple ou j'ai enlevé le nom des employés, je n'ai mis que 20 employes mais le fichier fait 4000 lignes quand il y a tous le monde

Pouvez vous m'aider ?

Je vous remercie d'avance pour votre aide

Romuald
 

Pièces jointes

  • Fichier test.xls
    65.5 KB · Affichages: 51
  • Fichier test.xls
    65.5 KB · Affichages: 55
  • Fichier test.xls
    65.5 KB · Affichages: 51

néné06

XLDnaute Accro
Re : Réalisation d'une macro

Bonsoir Romuald et bienvenue sur le Forum,

J'ai regardé ton post, mais je te propose de procéder étape par étape.

1. SUPPRESSION COLONNE E : C'est fait sur le modèle en retour, tu tapes (Ctrl k), qui supprimera la colonne E.
2. CODE 30 ET 1 ET 2 : SUPPRIMER LES LIGNES : Je ne détecte pas code 30,1,2 ?? quelles lignes à supprimer ??

Regardes le retour en PJ et donnes nous les renseignements !!

A te relire

René
 

Pièces jointes

  • Fichier test 03122013.xls
    70.5 KB · Affichages: 31

esterline.romuald

XLDnaute Nouveau
Re : Réalisation d'une macro

Bonjour,

J'ai ajouté des exemples
je vous redonne ce que je fais manuellement

1. SUPPRESSION COLONNE E
2. COLONNE F : CODE 30 : SUPPRIMER LES LIGNE
3. COLONNE F : CODE 1 : SUPPRIMER LES LIGNE
4. COLONNE F : CODE 2 : SUPPRIMER LES LIGNE
5. COLONNE F : CODE 11 : ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4 SAUF SI CTVAR 5 = 0
6. COLONNE F : CODE 43 : VSD : CTVAR 5 : 2,33 CTVAR92 : 6
7. COLONNE F : CODE 44 et 45 : CTVAR 5 : 3 CTVAR92 : 8
8. COLONNE F : CODE 61 : CTVAR 5 = 6,66
9. COLONNE F : CODE 63 : CTVAR 5 = 6,66
10.COLONNE F : CODE 64 NUIT : CTVAR 5 = 0,33 CTVAR92 : 7,75
11.COLONNE F : CODE 65 NUIT : CTVAR 5 = 3,50 CTVAR92 : 3,42
12.COLONNE F : NUMODJO : CODE 10 : ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4 SAUF SI CTVAR 5 = 0
13.FILTRE COLONNE CDACT : SI DES AI METTRE O DS CTVAR5
14.SI COLONNE CDACT = FERI ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4
15.SI COLONNE CDACT = HS SUR LE SAMEDI ON MET 0
16.SI HS JOUR DE LA SEMAINE ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4
17.SI PERSONNE MAL OU MAL 3 METTRE O DS CTVAR5
18.SI PERSONNE MIS : ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4
19.SUPPRIMER COLONNE APRES CTVAR 92
20.COLONNE CTVAR 92 : Si 1 mettre 0
21.Remplacer virgule par point
22.supprimer ligne d entete
23.enregistrer format csv

Le top serait que je n'ai juste à cliquer sur un bouton apres avoir collé toutes les données

Merci de votre aide

Romuald
 

Pièces jointes

  • Fichier test.xls
    71.5 KB · Affichages: 24
  • Fichier test.xls
    71.5 KB · Affichages: 27
  • Fichier test.xls
    71.5 KB · Affichages: 25

kingfadhel

XLDnaute Impliqué
Re : Réalisation d'une macro

Bonsoir,

à mon avis laisser la suppression des entetes et de la colonne E à la dernière étape.

2. 3. 6. 7. 10.

Code:
Sub MLK()
der = Sheets(1).Range("A65535").End(xlUp).Row
For i = 1 To Range("g1:g" & der).Count
    If Range("g" & i) = 1 Or Range("g" & i) = 2 Or Range("g" & i) = 30 Then
    Range("g" & i).EntireRow.Delete
    End If
Next
For i = 1 To Range("G1:G" & der).Count
    If Range("g" & i) = 10 or Range("g" & i) = 11 Then
        If Range("i" & i) = 0 Then
        Range("i" & i) = Range("h" & i)
        End If
    End If
Next
For i = 1 To Range("G1:G" & der).Count
    If Range("g" & i) = 61 Or Range("g" & i) = 63 Then
        Range("i" & i) = CDbl("6,66")
    End If
Next
End Sub
 
Dernière édition:

néné06

XLDnaute Accro
Re : Réalisation d'une macro

Re,

Dans l'exemple que j'ai placé, si tu ouvre le fichier "Fichier test03122013", tu appuis sur les touches "Ctrl et K", cela te supprimera la colonne E.
Essayes en appuyant plusieurs fois sur les touches Ctrl et K, tu verras que à chaque appuis, le colonne E est supprimé.
Pour continuer la macro, je dois savoir ce que tu entends par: " COLONNE F : CODE 30 : SUPPRIMER LES LIGNE " ?????

A+

Edit: Bonsoir Kingfadhel
 
Dernière édition:

kingfadhel

XLDnaute Impliqué
Re : Réalisation d'une macro

Re,
Bonsoir le fil,

Je demande des explications :

6. COLONNE F : CODE 43 : VSD : CTVAR 5 : 2,33 CTVAR92 : 6 // VSD???

10.COLONNE F : CODE 64 NUIT : CTVAR 5 = 0,33 CTVAR92 : 7,75 // Nuit??
11.COLONNE F : CODE 65 NUIT : CTVAR 5 = 3,50 CTVAR92 : 3,42 // Nuit??

13.FILTRE COLONNE CDACT : SI DES AI METTRE O DS CTVAR5 // on peut mettre O ou 0 sans le filtrage

15.SI COLONNE CDACT = HS SUR LE SAMEDI ON MET 0 // HS???
16.SI HS JOUR DE LA SEMAINE ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4
17.SI PERSONNE MAL OU MAL 3 METTRE O DS CTVAR5 // MAL???
18.SI PERSONNE MIS : ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4 //MIS???

21.Remplacer virgule par point // quelle virgule???
22.supprimer ligne d entete
23.enregistrer format csv
 

esterline.romuald

XLDnaute Nouveau
Re : Réalisation d'une macro

Bonjour

Voici mes retours

6. COLONNE F : CODE 43 : CTVAR 5 : 2,33 CTVAR92 : 6
10.COLONNE F : CODE 64 : CTVAR 5 = 0,33 CTVAR92 : 7,75
11.COLONNE F : CODE 65 : CTVAR 5 = 3,50 CTVAR92 : 3,42

13.FILTRE COLONNE CDACT : SI DES AI METTRE O DS CTVAR5 // je vous laisse faire comme vous voulez
15.SI COLONNE CDACT = HS SUR LE SAMEDI ON MET 0 // g ajouter un exemple
16.SI HS JOUR DE LA SEMAINE ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4
17.SI PERSONNE MAL OU MAL 3 METTRE O DS CTVAR5 // MAL??? // g ajouter un exemple
18.SI PERSONNE MIS : ALORS CTVAR5 DOIT ETRE EGALE A CTVAR4 //MIS??? // g ajouter un exemple

ne pas tenir compte du numéro 21

Pour néné06 : quand colonne NUMODJOU est égal à 30 supprimer les lignes
 

Pièces jointes

  • Fichier test.xls
    72 KB · Affichages: 30
  • Fichier test.xls
    72 KB · Affichages: 31
  • Fichier test.xls
    72 KB · Affichages: 22

kingfadhel

XLDnaute Impliqué
Re : Réalisation d'une macro

Bonjour,

Dans un module tu colles le code suivant


Code:
Sub esterline_romuald()
der = Sheets(1).Range("A65535").End(xlUp).Row
For i = 2 To Range("g2:g" & der).Count
    'Rq 5 et 12
    If Range("g" & i) = 10 Or Range("g" & i) = 11 Then
        If Range("i" & i) = 0 Then
        Range("i" & i) = Range("h" & i)
        End If
    End If
    'Rq 8 et 9
    If Range("g" & i) = 61 Or Range("g" & i) = 63 Then
        Range("i" & i) = ("6.66")
    End If
    'Rq 20
    If Range("h" & i) = 1 Then
        Range("h" & i) = 0
    End If
    'Rq 7
    If Range("g" & i) = 44 Or Range("g" & i) = 45 Then
        Range("i" & i) = ("3")
        Range("J" & i) = ("8")
    End If
    'Rq 6
    If Range("g" & i) = 43 Then
        Range("i" & i) = ("2.33")
        Range("J" & i) = ("6")
    End If
    'Rq 10
    If Range("g" & i) = 64 Then
        Range("i" & i) = ("0.33")
        Range("J" & i) = ("7.75")
    End If
    'Rq 11
    If Range("g" & i) = 65 Then
        Range("i" & i) = ("3.5")
        Range("J" & i) = ("3.42")
    End If
    'Rq 13 et 17
    If Range("D" & i) = "AI" Or Range("D" & i) = "MAL" Or Range("D" & i) = "MAL 3" Then
        Range("i" & i) = ("0")
    End If
    'Rq 15
    If Range("D" & i) = "HS" And Weekday(Range("c" & i)) = 6 Then
        Range("i" & i) = ("0")
    End If
    'Rq 16
    If Range("D" & i) = "HS" And Weekday(Range("c" & i)) < 6 Then
        Range("i" & i) = Range("h" & i)
    End If
    'Rq 14 et 18
    If Range("D" & i) = "FERI" Or Range("D" & i) = "MIS" Then
        Range("i" & i) = Range("h" & i)
    End If
    'Rq 2 , 3 et 4
    If Range("g" & i) = 1 Or Range("g" & i) = 2 Or Range("g" & i) = 30 Then
    Range("g" & i).EntireRow.Delete
    End If
Next
End Sub

Sub Supp_Tete_Cols()
    'Rq 19
    Columns("K:V").Select
    Selection.Delete Shift:=xlToLeft
    'Rq 22
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
    'Rq 1
    Columns("E:E").Select
    Selection.Delete Shift:=xlToLeft
End Sub

RQ

- Pour la 1ére macro Sub esterline_romuald() actuellement tu l'exécute plusieurs fois de suite, car s'il y a deux lignes successifs contenant le meme code recherché, le deuxième sera dépasser.

- Une fois tu es sure que toutes les lignes supprimées (selon les critères), tu exécutes la deuxième macro Sub Supp_Tete_Cols().
 
Dernière édition:

esterline.romuald

XLDnaute Nouveau
Re : Réalisation d'une macro

Bonjour

J'ai essayé de mettre la 1er macro en place mais j'ai un message de débogage 'erreur 13)

Je te joint un imprime écran

Et encore merci pour ton aide

Romuald
 

Pièces jointes

  • Erreur.jpg
    Erreur.jpg
    88.5 KB · Affichages: 40
  • Erreur.jpg
    Erreur.jpg
    88.5 KB · Affichages: 43
  • Erreur.jpg
    Erreur.jpg
    88.5 KB · Affichages: 45

kingfadhel

XLDnaute Impliqué
Re : Réalisation d'une macro

Bonjour

J'ai essayé de mettre la 1er macro en place mais j'ai un message de débogage 'erreur 13)

Je te joint un imprime écran

Et encore merci pour ton aide

Romuald

Re,
Résolu...

ton fichier en retour.
 

Pièces jointes

  • Fichier test-1.xls
    73.5 KB · Affichages: 28
  • Fichier test-1.xls
    73.5 KB · Affichages: 29
  • Fichier test-1.xls
    73.5 KB · Affichages: 24

esterline.romuald

XLDnaute Nouveau
Re : Réalisation d'une macro

Bonjour kingfadhel

Merci beaucoup pour ton aide, il reste juste une chose quand le code est égale à 10 et à 11 : CTVAR5 doit être égale à CTVAR4
et dans ton fichier cela ne fonctionne pas

J'ai modifié manuellement mais peux tu m'aider à résoudre ce problème

Merci

Romuald
 

Discussions similaires

Réponses
22
Affichages
894
Réponses
7
Affichages
584

Statistiques des forums

Discussions
312 508
Messages
2 089 138
Membres
104 047
dernier inscrit
bravetta