Bonjour,

Encore une fois me revoilà pour vous questionner sur un problème que je rencontre dans ma macro Excel.

Pour résumer, celle-ci me permet de me connecter grâce aux fonctions de ADODB à un classeur fermé pour y récupérer les informations.

Ensuite je trie les informations que je souhaite ( oui je sais je pourrais récupérer que les info que j'aimerais mais chaque chose en son temps )

Bref, ensuite le but final est de récupérer des fichiers .txt pour attaquer le serv et tout balancer dessus.

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
 
Sub CreationScript()
 
    Dim derLigneFeuil As Integer
    Dim derLigneScript As Integer
 
    Sheets(3).Select
 
    derLigneFeuil = Cells.Find("*", , , , xlByRows, xlPrevious).Row
 
    Sheets(7).Select
    Sheets(7).UsedRange.ClearContents ' On efface toutes les cellulces avec du contenu
    Range("B1").Value = "Update Required Obj"
    Range("C1").Value = "Insert Personal Obj"
    Range("E1").Value = "Update PDP"
    Range("F1").Value = "Update Mob"
 
 
    For i = 2 To (derLigneFeuil + 1)
        Cells(i, 2) = "=" & Chr(34) & "Update PS_EP_APPR_B_ITEM set EP_WEIGHT=" & Chr(34) & "&Sheet3!I" & (i - 1) & "*100&" _
            & Chr(34) & "where ep_appraisal_id =(select max(ep_appraisal_id) from ps_ep_appr where EMPLID=" & Chr(34) & "&Sheet3!A" _
            & i & "&" & Chr(34) & "') and EP_ITEM_SEQ=" & Chr(34) & "&A2&" & Chr(34) & " and EP_SECTION_TYPE='UBPGLS' and ep_item_id=' ';'" & Chr(34)
 
    Next
 
    Sheets(6).Select
 
    derLigneFeuil = Cells.Find("*", , , , xlByRows, xlPrevious).Row
 
    Sheets(7).Select
 
    For i = 2 To (derLigneFeuil + 1)
 
        Cells(i, 3) = "" & Chr(34) & "Insert into PS_EP_APPR_B_ITEM select max(EP_APPRAISAL_ID),'UBPGLS',' '," & Chr(34) & _
            "&Sheet6!K" & (i - 1) & "&" & Chr(34) & ",'" & Chr(34) & "&GAUCHE(SUBSTITUE(Sheet6!C" & (i - 1) & ";" & Chr(34) & "'" & Chr(34) & _
            ";" & Chr(34) & "''" & Chr(34) & ");60)&" & Chr(34) & "','UBP1',0," & Chr(34) & "&Sheet6!I" & (i - 1) & "*100&" & Chr(34) & _
            ",null,null,'N','N',' ',' ',' ','U',' '," & Chr(34)
            'Cells(i, 3) = "=" & Cells(i, 3)
 
        Cells(i, 4) = "" & Chr(34) & "'" & Chr(34) & "&SUBSTITUE(Sheet6!D" & (i - 1) & ";" & Chr(34) & "'" & Chr(34) & ";" & Chr(34) & "''" & Chr(34) & ")&" & Chr(34) & "', '" & Chr(34) & "&CONCATENER(" & Chr(34) & _
            "Q4 : " & Chr(34) & ";SUBSTITUE(Sheet6!E" & (i - 1) & ";" & Chr(34) & "'" & Chr(34) & ";" & Chr(34) & "''" & Chr(34) & ");CAR(10);" & Chr(34) & "Q3 : " & Chr(34) & ";SUBSTITUE(Sheet6!F" & (i - 1) & ";" & Chr(34) & "'" & Chr(34) & _
            ";" & Chr(34) & "''" & Chr(34) & ");CAR(10); " & Chr(34) & "Q2 : " & Chr(34) & ";SUBSTITUE(Sheet6!G" & (i - 1) & ";" & Chr(34) & "'" & Chr(34) & ";" & Chr(34) & "''" & Chr(34) & ");CAR(10); " & Chr(34) & "Q1 : " & Chr(34) & _
            ";SUBSTITUE(Sheet6!H" & (i - 1) & ";" & Chr(34) & "'" & Chr(34) & ";" & Chr(34) & "''" & Chr(34) & "))&" & Chr(34) & "',' ',0,'N','N',null,null,null,0,' ',0,0,' ',' ','P',null,0,' ',sysdate,' ',null,' ','C'  from ps_ep_appr where EMPLID='" _
            & Chr(34) & "&Sheet6!A1&" & Chr(34) & "';" & Chr(34)
 
        Cells(i, 5) = "" & Chr(34) & "Update PS_EP_APPR_B_ITEM set EP_DESCR254='" & Chr(34) & "&SUBSTITUE(Sheet4!D" & (i - 1) & ";" & Chr(34) & "'" & Chr(34) & ";" & Chr(34) & "''" & Chr(34) & ")&" & Chr(34) & _
        "' where ep_appraisal_id = (select max(ep_appraisal_id) from ps_ep_appr where EMPLID='" & Chr(34) & "&Sheet4!A" & i & "&" & Chr(34) & "') and EP_ITEM_SEQ=1 and EP_SECTION_TYPE='UBPLEARN';" & Chr(34)
 
        Cells(i, 6) = "" & Chr(34) & "Update PS_EP_APPR_B_ITEM set EP_DESCR254='" & Chr(34) & "&SUBSTITUE(Sheet5!D" & (i - 1) & ";" & Chr(34) & "'" & Chr(34) & ";" & Chr(34) & "''" & Chr(34) & _
        ")&" & Chr(34) & "' where ep_appraisal_id = (select max(ep_appraisal_id) from ps_ep_appr where EMPLID='" & Chr(34) & "&Sheet5!A" & (i - 1) & "&" & Chr(34) & "') and EP_ITEM_SEQ=1 and EP_SECTION_TYPE='UBPMOBIL';" & Chr(34)
 
 
    Next
 
End Sub
Voila le petit bout de code bien relou à écrire... Bien évidemment pour les quatre derniers scripts j'ai essayer de mettre un "=" entre les guillemets mais il me sort une erreur alors que pour le premier ça passe nickel chrome...

Si je rajoute le "=" à la main alors la plus aucun soucis tout marche très bien ( mais bon le but c'est qu'il le fasse tous seul)

Est-ce que quelqu'un aurait une solution pour l'obliger à rajouter le égal sans que ça claque?

P-S: Ça fait quatre heures que je suis sur ces scripts et j'ai l'impression que Excel me troll. Je suis entrain de devenir fou... Merci à l'âme charitable qui pourra me sortir de cette impasse.