Sub ajouter() [A1].Formula = [A1].Formula & "+" & [B1] End Sub
La 2° fois et les fois suivantes : Sub ajouter2() x = [A1].Formula [A1].Formula = Left(x, InStrRev(x, "+") - 1) & "+" & [B1] End Sub
Etc
gmlsteph
Bonjour,
si en revanche tu souhaites automatiser l'ajout à A1 de chaque saisie en B1, mettre ceci dans le code de la feuille:
Private Sub Worksheet_Change(ByVal Target As Range) Dim iSect As Range Set iSect = Intersect(Target, [B1]) If iSect Is Nothing Then Exit Sub On Error GoTo fin Application.EnableEvents = False If IsNumeric(iSect) Then [a1].Formula = [a1].Formula & "+" & iSect.Value End If fin: Application.EnableEvents = True End Sub
'lSteph
On 4 juin, 08:53, ericlbt wrote:
Bonjour,
Je suis à la recherche d'une macro qui permette d'ajouter un nombre à une formule existante.
Exemple : A1 : +20+30 B1 : 123 Résultat à obtenir en A1 : +20+30+123
Merci par avance pour votre aide.
Bonjour,
si en revanche tu souhaites automatiser l'ajout à A1 de chaque saisie
en B1,
mettre ceci dans le code de la feuille:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iSect As Range
Set iSect = Intersect(Target, [B1])
If iSect Is Nothing Then Exit Sub
On Error GoTo fin
Application.EnableEvents = False
If IsNumeric(iSect) Then
[a1].Formula = [a1].Formula & "+" & iSect.Value
End If
fin:
Application.EnableEvents = True
End Sub
'lSteph
On 4 juin, 08:53, ericlbt <eric...@discussions.microsoft.com> wrote:
Bonjour,
Je suis à la recherche d'une macro qui permette d'ajouter un nombre à une
formule existante.
Exemple :
A1 : =10+20+30
B1 : 123
Résultat à obtenir en A1 : =10+20+30+123
si en revanche tu souhaites automatiser l'ajout à A1 de chaque saisie en B1, mettre ceci dans le code de la feuille:
Private Sub Worksheet_Change(ByVal Target As Range) Dim iSect As Range Set iSect = Intersect(Target, [B1]) If iSect Is Nothing Then Exit Sub On Error GoTo fin Application.EnableEvents = False If IsNumeric(iSect) Then [a1].Formula = [a1].Formula & "+" & iSect.Value End If fin: Application.EnableEvents = True End Sub
'lSteph
On 4 juin, 08:53, ericlbt wrote:
Bonjour,
Je suis à la recherche d'une macro qui permette d'ajouter un nombre à une formule existante.
Exemple : A1 : +20+30 B1 : 123 Résultat à obtenir en A1 : +20+30+123