Se connecter avec
S'enregistrer | Connectez-vous

Condition sur du texte

Dernière réponse : dans Programmation

bonjour
ci dessous il y a un code mais j'ai une erreur a la lige 10:"erreur definie par l'application ou par l'objet " :??: 
voila ce j'essai de faire :
en colonne E j'ai des texte et sur chaque ligne en colonne P je voudrai mettre les caracteres qui corespondent BBB,AAA......ect

  1. Sub rating_note()
  2. Dim k As Long, i As Long
  3. Dim ws_f As Worksheet
  4. k = Worksheets("Feuil1").Cells(Rows.Count, 1).End(xlUp).Row
  5. Set ws_f = Worksheets("Feuil1")
  6.  
  7. For i = 0 To k - 6
  8.  
  9. If ws_f.Cells(i + 6, 5).Text Like "*MICHELIN LUX SCS*" Then
  10. ws_f.Cells(i + 6, 16).Text = "BBB"
  11. ElseIf ws_f.Cells(i + 6, 5).Text Like "*SCHNEI*" Then
  12. ws_f.Cells(i + 6, 16).Text = " A-"
  13. ElseIf ws_f.Cells(i + 6, 5).Text Like "*WENDEL INV*" Then
  14. ws_f.Cells(i + 6, 16).Text = "BB"
  15. ElseIf ws_f.Cells(i + 6, 5).Text Like "*RENAULT*" Then
  16. ws_f.Cells(i + 6, 16).Text = "BB"
  17. 'UPM KYMMENE 6.125% 01/201
  18. ElseIf ws_f.Cells(i + 6, 5).Text Like "*REPSOL INT FIN*" Then
  19. ws_f.Cells(i + 6, 16).Text = " BBB"
  20. ElseIf ws_f.Cells(i + 6, 5).Text Like "*SODEXHO*" Then
  21. ws_f.Cells(i + 6, 16).Text = "BBB+"
  22. ElseIf ws_f.Cells(i + 6, 5).Text Like "*OTE PLC*" Then
  23. ws_f.Cells(i + 6, 16).Text = "BBB-"
  24. ElseIf ws_f.Cells(i + 6, 5).Text Like "*PUBLICIS*" Then
  25. ws_f.Cells(i + 6, 16).Text = "BBB+"
  26.  
  27. 'SCHERING-PLOUGH 5.375% 01
  28. ElseIf ws_f.Cells(i + 6, 5).Text Like "*TECHNIP SA *" Then
  29. ws_f.Cells(i + 6, 16).Text = "BBB+"
  30. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BERTELSMANN AG *" Then
  31. ws_f.Cells(i + 6, 16).Text = "BBB"
  32. ElseIf ws_f.Cells(i + 6, 5).Text Like "*SUEDZUCKER*" Then
  33. ws_f.Cells(i + 6, 16).Text = "BBB"
  34. ElseIf ws_f.Cells(i + 6, 5).Text Like "*KRAFT FOODS INC*" Then
  35. ws_f.Cells(i + 6, 16).Text = "BBB"
  36. ElseIf ws_f.Cells(i + 6, 5).Text Like "*WOLTERS KLUWER*" Then
  37. ws_f.Cells(i + 6, 16).Text = "BBB+"
  38. 'TCHIBO HOLDING 4.50% 10/2
  39. ElseIf ws_f.Cells(i + 6, 5).Text Like "*GROUP NYSE EURONEXT*" Then
  40. ws_f.Cells(i + 6, 16).Text = "AA-"
  41. ElseIf ws_f.Cells(i + 6, 5).Text Like "*ADECCO INT FIN SBV*" Then
  42. ws_f.Cells(i + 6, 16).Text = "BBB-"
  43. ElseIf ws_f.Cells(i + 6, 5).Text Like "*LAFARGE*" Then
  44. ws_f.Cells(i + 6, 16).Text = "BBB-"
  45. ElseIf ws_f.Cells(i + 6, 5).Text Like "*ATT INC*" Then
  46. ws_f.Cells(i + 6, 16).Text = "A"
  47. ElseIf ws_f.Cells(i + 6, 5).Text Like "*OAT*" Then
  48. ws_f.Cells(i + 6, 16).Text = "AAA"
  49. ElseIf ws_f.Cells(i + 6, 5).Text Like "*CEDULAS TDA*" Then
  50. ws_f.Cells(i + 6, 16).Text = "AAA"
  51. ElseIf ws_f.Cells(i + 6, 5).Text Like "*DEXIA MPAL AGENCY*" Then
  52. ws_f.Cells(i + 6, 16).Text = "AAA"
  53. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BELGELEC FIN*" Then
  54. ws_f.Cells(i + 6, 16).Text = "A"
  55. ElseIf ws_f.Cells(i + 6, 5).Text Like "*CFF*" Then
  56. ws_f.Cells(i + 6, 16).Text = "AAA"
  57. ElseIf ws_f.Cells(i + 6, 5).Text Like "*LA POSTE*" Then
  58. ws_f.Cells(i + 6, 16).Text = "A"
  59. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BAYER *" Then
  60. ws_f.Cells(i + 6, 16).Text = "A-"
  61. ElseIf ws_f.Cells(i + 6, 5).Text Like "*EIB *" Then
  62. ws_f.Cells(i + 6, 16).Text = "AAA"
  63. ElseIf ws_f.Cells(i + 6, 5).Text Like "*EDF*" Then
  64. ws_f.Cells(i + 6, 16).Text = "A+"
  65. ElseIf ws_f.Cells(i + 6, 5).Text Like "*GOVT OF SPAIN*" Then
  66. ws_f.Cells(i + 6, 16).Text = "AA+"
  67. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BPCE*" Then
  68. ws_f.Cells(i + 6, 16).Text = "A+"
  69. ElseIf ws_f.Cells(i + 6, 5).Text Like "*GRECE*" Then
  70. ws_f.Cells(i + 6, 16).Text = "BBB+"
  71.  
  72. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BEI*" Then
  73. ws_f.Cells(i + 6, 16).Text = "AAA"
  74.  
  75. 'EUROP INVEST BK 4.625% 04
  76. ElseIf ws_f.Cells(i + 6, 5).Text Like "*ITW FINANCE EUR*" Then
  77. ws_f.Cells(i + 6, 16).Text = "A+"
  78.  
  79.  
  80. 'STE SFR SA 3.375% 07/12
  81.  
  82.  
  83.  
  84.  
  85.  
  86. 'AIR Products And CHEMICAL
  87. 'AIR Products And CHEMICAL
  88. ElseIf ws_f.Cells(i + 6, 5).Text Like "*INVESTOR AB*" Then
  89. ws_f.Cells(i + 6, 16).Text = "AA-"
  90. ElseIf ws_f.Cells(i + 6, 5).Text Like "*CENTRICA PLC*" Then
  91. ws_f.Cells(i + 6, 16).Text = "A-"
  92. ElseIf ws_f.Cells(i + 6, 5).Text Like "*IBERDROLA*" Then
  93. ws_f.Cells(i + 6, 16).Text = "A-"
  94. ElseIf ws_f.Cells(i + 6, 5).Text Like "*LVMH*" Then
  95. ws_f.Cells(i + 6, 16).Text = "A-"
  96. ElseIf ws_f.Cells(i + 6, 5).Text Like "*SIEMENS*" Then
  97. ws_f.Cells(i + 6, 16).Text = "A+"
  98. ElseIf ws_f.Cells(i + 6, 5).Text Like "*SANDVIK AB*" Then
  99. ws_f.Cells(i + 6, 16).Text = "BBB"
  100. ElseIf ws_f.Cells(i + 6, 5).Text Like "*STATOILHYDRO ASA*" Then
  101. ws_f.Cells(i + 6, 16).Text = "AA-"
  102. ElseIf ws_f.Cells(i + 6, 5).Text Like "*IBM CORP*" Then
  103. ws_f.Cells(i + 6, 16).Text = "A+"
  104. ElseIf ws_f.Cells(i + 6, 5).Text Like "*AUCHAN*" Then
  105. ws_f.Cells(i + 6, 16).Text = "A"
  106.  
  107. ElseIf ws_f.Cells(i + 6, 5).Text Like "*DANAHER*" Then
  108. ws_f.Cells(i + 6, 16).Text = "BBB+"
  109. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BTP ITALIE*" Then
  110. ws_f.Cells(i + 6, 16).Text = "A+"
  111. ElseIf ws_f.Cells(i + 6, 5).Text Like "*GE CAPITAL EUR FUNDING*" Then
  112. ws_f.Cells(i + 6, 16).Text = "AA+"
  113. ElseIf ws_f.Cells(i + 6, 5).Text Like "*ABERTIS INFRA*" Then
  114. ws_f.Cells(i + 6, 16).Text = "A-"
  115. ElseIf ws_f.Cells(i + 6, 5).Text Like "*SCHNEIDER*" Then
  116. ws_f.Cells(i + 6, 16).Text = "A-"
  117. ElseIf ws_f.Cells(i + 6, 5).Text Like "*DEUT TELEKOM*" Then
  118. ws_f.Cells(i + 6, 16).Text = "A"
  119. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BOUYGUES*" Then
  120. ws_f.Cells(i + 6, 16).Text = "A-"
  121. ElseIf ws_f.Cells(i + 6, 5).Text Like "*PEUGEOT*" Then
  122. ws_f.Cells(i + 6, 16).Text = "BB+"
  123. ElseIf ws_f.Cells(i + 6, 5).Text Like "*FRANCE TELECOM*" Then
  124. ws_f.Cells(i + 6, 16).Text = "A-"
  125. ElseIf ws_f.Cells(i + 6, 5).Text Like "*MERCK FINANZ AG*" Then
  126. ws_f.Cells(i + 6, 16).Text = "BBB+"
  127. ElseIf ws_f.Cells(i + 6, 5).Text Like "*ASTRAZENECA PLC*" Then
  128. ws_f.Cells(i + 6, 16).Text = "AA-"
  129. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BRISA*" Then
  130. ws_f.Cells(i + 6, 16).Text = "BBB"
  131. ElseIf ws_f.Cells(i + 6, 5).Text Like "*ATLANTIA SPA*" Then
  132. ws_f.Cells(i + 6, 16).Text = "A-"
  133. ElseIf ws_f.Cells(i + 6, 5).Text Like "*KONINKLIJKE DSM NV*" Then
  134. ws_f.Cells(i + 6, 16).Text = "A-"
  135. ElseIf ws_f.Cells(i + 6, 5).Text Like "*ANGLIAN WA*" Then
  136. ws_f.Cells(i + 6, 16).Text = "A-"
  137. ElseIf ws_f.Cells(i + 6, 5).Text Like "*RODAMCO EUR FIN BV*" Then
  138. ws_f.Cells(i + 6, 16).Text = "A"
  139. ElseIf ws_f.Cells(i + 6, 5).Text Like "*ATLAS COPCO AB*" Then
  140. ws_f.Cells(i + 6, 16).Text = "A-"
  141. ElseIf ws_f.Cells(i + 6, 5).Text Like "*VOLKSWAGEN*" Then
  142. ws_f.Cells(i + 6, 16).Text = "A-"
  143. ElseIf ws_f.Cells(i + 6, 5).Text Like "*GE CAP EUR FUND*" Then
  144. ws_f.Cells(i + 6, 16).Text = "AA+"
  145. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BMW US CAPITAL LLC*" Then
  146. ws_f.Cells(i + 6, 16).Text = "A-"
  147. ElseIf ws_f.Cells(i + 6, 5).Text Like "*ROYAUME DE BELGIQUE*" Then
  148. ws_f.Cells(i + 6, 16).Text = "A+"
  149. ElseIf ws_f.Cells(i + 6, 5).Text Like "*BANQUES POPULAIRES*" Then
  150. ws_f.Cells(i + 6, 16).Text = "AAA"
  151. Else
  152. ws_f.Cells(i + 6, 16).Text = ""
  153. End If
  154.  
  155. Next
  156. End Sub


merci d'avance :) 

Autres pages sur : condition texte

Lassé par la pub ? Créez un compte
Lassé par la pub ? Créez un compte