Help script VBA
Résolu
Mon6760
Messages postés
3
Date d'inscription
Statut
Membre
Dernière intervention
-
yg_be Messages postés 23541 Date d'inscription Statut Contributeur Dernière intervention -
yg_be Messages postés 23541 Date d'inscription Statut Contributeur Dernière intervention -
A voir également:
- Help script VBA
- Script vidéo youtube - Guide
- Mas script - Accueil - Windows
- Ghost script - Télécharger - Polices de caractères
- Excel compter cellule couleur sans vba - Guide
- Script cmd - Guide
3 réponses
yg_be
Messages postés
23541
Date d'inscription
Statut
Contributeur
Dernière intervention
Ambassadeur
1 584
bonsoir, une piste:
Option Explicit Sub Mail_Workbook_1() Dim Tyype As String Dim Region As String Dim Impact As String Dim Reference As String Dim JourdeHICreation As String Dim SumEUR As String Dim Amount As String Dim textemsg As String Dim lig As Range Dim FL As Worksheet 'stocker la valeur du classeur actif Dim OutApp As Object Dim OutMail As Object Set FL = Worksheets("Weekly") For Each lig In FL.UsedRange.Rows Tyype = lig(1, 9) Region = lig(1, 4) Impact = lig(1, 7) Reference = lig(1, 2) JourdeHICreation = lig(1, 10) SumEUR = lig(1, 1) Amount = lig(1, 11) textemsg = textemsg _ & Reference & " " & "(" & JourdeHICreation & "/" & " " & "/" & Tyype & "/" & "EUR " & Amount & " K" & ")" Next lig Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .To = "" .CC = "" .BCC = "" .Subject = "" .Body = textemsg .Display End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub
Merci bcp, effectivement c'est plus logique comme cela. Le problème est que je n'arrive pas a récupérer la valeur des autres lignes... j'ai essayer ca:
Mais cela ne sélectionne que la ligne et l'écrit plusieurs fois...
Merci beaucoup pour votre aide!
Option Explicit
Sub Mail_Workbook_1()
Dim Tyype As String
Dim Region As String
Dim Impact As String
Dim Reference As String
Dim JourdeCreation As String
Dim SumEUR As String
Dim Amount As String
Dim LineNB, ColNB As Long
Dim textemsg As String
Dim lig As Range
Dim FL As Worksheet 'stocker la valeur du classeur actif
Set FL = Worksheets("Weekly_breakdown_crosstab")
LineNB = ActiveCell.Row
For Each lig In FL.UsedRange.Rows
Tyype = FL.Cells(LineNB, 9).Value
Region = FL.Cells(LineNB, 4).Value
Impact = FL.Cells(LineNB, 8).Value
Reference = FL.Cells(LineNB, 2).Value
JourdeCreation = FL.Cells(LineNB, 10).Value
SumEUR = FL.Cells(LineNB, 1).Value
Amount = FL.Cells(LineNB, 11).Value
textemsg = textemsg _
& Reference & " " & "(" &JourdeCreation& "/" & " " & "/" & Impact & "/" & "EUR " & Amount & ")"
Next lig
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = ""
.Body = textemsg
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Mais cela ne sélectionne que la ligne et l'écrit plusieurs fois...
Merci beaucoup pour votre aide!