Help script VBA
Résolu/Fermé
Mon6760
Messages postés
3
Date d'inscription
mardi 8 mai 2018
Statut
Membre
Dernière intervention
9 mai 2018
-
Modifié le 8 mai 2018 à 18:01
yg_be Messages postés 22717 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 22 avril 2024 - 9 mai 2018 à 12:47
yg_be Messages postés 22717 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 22 avril 2024 - 9 mai 2018 à 12:47
A voir également:
- Help script VBA
- Script vidéo youtube - Guide
- Incompatibilité de type vba ✓ - Forum Programmation
- Vba attendre 1 seconde ✓ - Forum VB / VBA
- Vba dernière colonne non vide ✓ - Forum VB / VBA
- Vba récupérer valeur cellule ✓ - Forum VB / VBA
3 réponses
yg_be
Messages postés
22717
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
22 avril 2024
1 474
8 mai 2018 à 20:47
8 mai 2018 à 20:47
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
Mon6760
Messages postés
3
Date d'inscription
mardi 8 mai 2018
Statut
Membre
Dernière intervention
9 mai 2018
Modifié le 9 mai 2018 à 11:48
Modifié le 9 mai 2018 à 11:48
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!
Mon6760
Messages postés
3
Date d'inscription
mardi 8 mai 2018
Statut
Membre
Dernière intervention
9 mai 2018
9 mai 2018 à 12:11
9 mai 2018 à 12:11
J'ai reussi, merci bcp pour la piste !
yg_be
Messages postés
22717
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
22 avril 2024
1 474
9 mai 2018 à 12:47
9 mai 2018 à 12:47
super! peux-tu alors marquer le sujet comme résolu, via la roue dentée à droite du titre?