castlevania
XLDnaute Nouveau
Bonjour,
Je me tourne vers les spécialistes Excel car je rencontre un petit soucis:
j'ai trouvé sur internet une macro qui correspondrait à mes besoins en EMAIL envoyé par EXCEL.
elle fonctionne très bien sur une feuille contenant 7 lignes mais pose un problème par transposition sur ma feuille qui peut en contenir +500.
En colonne B, j'ai une valeur qui déclenche ou non l'envoi d'un EMAIL, si cette valeur est supérieur à 200.
le soucis avec la transposition a mon fichier, c'est que j'ai augmenter
"Set FormulaRange = Me.Range("b8:b500")"
ce qui fait que dès que je touche a ma feuille, excel se met à calculer.
Y'a til un moyen de lui imposer la ligne "en cours" uniquement?
voiçi le code:
Private Sub Worksheet_Calculate()
Dim FormulaRange As Range
Dim NotSentMsg As String
Dim MyMsg As String
Dim SentMsg As String
Dim MyLimit As Double
NotSentMsg = "RAS"
SentMsg = "envoyé"
'Above the MyLimit value it will run the macro
MyLimit = 200
'Set the range with Formulas that you want to check
Set FormulaRange = Me.Range("b8:b500")
On Error GoTo EndMacro:
For Each FormulaCell In FormulaRange.Cells
With FormulaCell
If IsNumeric(.Value) = False Then
MyMsg = "Not numeric"
Else
If .Value > MyLimit Then
MyMsg = SentMsg
If .Offset(0, 1).Value = NotSentMsg Then
Call Mail_with_outlook2
End If
Else
MyMsg = NotSentMsg
End If
End If
Application.EnableEvents = False
.Offset(0, 1).Value = MyMsg
Application.EnableEvents = True
End With
Next FormulaCell
ExitMacro:
Exit Sub
EndMacro:
Application.EnableEvents = True
MsgBox "une erreur est survenu." _
& vbLf & Err.Number _
& vbLf & Err.Description
End Sub
j'aimerais que cette macro ne rafraichisse pas toutes les lignes mais seulement celle active.
Je vous joins un fichier de démonstration. Ce serait vraiment gentil de m'aider
Merci de votre aide précieuse.
Je me tourne vers les spécialistes Excel car je rencontre un petit soucis:
j'ai trouvé sur internet une macro qui correspondrait à mes besoins en EMAIL envoyé par EXCEL.
elle fonctionne très bien sur une feuille contenant 7 lignes mais pose un problème par transposition sur ma feuille qui peut en contenir +500.
En colonne B, j'ai une valeur qui déclenche ou non l'envoi d'un EMAIL, si cette valeur est supérieur à 200.
le soucis avec la transposition a mon fichier, c'est que j'ai augmenter
"Set FormulaRange = Me.Range("b8:b500")"
ce qui fait que dès que je touche a ma feuille, excel se met à calculer.
Y'a til un moyen de lui imposer la ligne "en cours" uniquement?
voiçi le code:
Private Sub Worksheet_Calculate()
Dim FormulaRange As Range
Dim NotSentMsg As String
Dim MyMsg As String
Dim SentMsg As String
Dim MyLimit As Double
NotSentMsg = "RAS"
SentMsg = "envoyé"
'Above the MyLimit value it will run the macro
MyLimit = 200
'Set the range with Formulas that you want to check
Set FormulaRange = Me.Range("b8:b500")
On Error GoTo EndMacro:
For Each FormulaCell In FormulaRange.Cells
With FormulaCell
If IsNumeric(.Value) = False Then
MyMsg = "Not numeric"
Else
If .Value > MyLimit Then
MyMsg = SentMsg
If .Offset(0, 1).Value = NotSentMsg Then
Call Mail_with_outlook2
End If
Else
MyMsg = NotSentMsg
End If
End If
Application.EnableEvents = False
.Offset(0, 1).Value = MyMsg
Application.EnableEvents = True
End With
Next FormulaCell
ExitMacro:
Exit Sub
EndMacro:
Application.EnableEvents = True
MsgBox "une erreur est survenu." _
& vbLf & Err.Number _
& vbLf & Err.Description
End Sub
j'aimerais que cette macro ne rafraichisse pas toutes les lignes mais seulement celle active.
Je vous joins un fichier de démonstration. Ce serait vraiment gentil de m'aider
Merci de votre aide précieuse.