Autres [RESOLU] effacer un nombre dans une cellule

un internaute

XLDnaute Impliqué
Bonjour le forum
Dans une cellule j'ai par exemple 100 € je l'efface je voudrais qu'il soit remplacé par 0.00 €
Je ne trouve pas dans format personnalisé
Merci pour vos éventuels retours
 

Eric C

XLDnaute Barbatruc
Bonsoir le forum
Bonsoir un internaute

Vraiment tiré par les cheveux. La cellule étant "A1". En V1 ou ailleurs (plus loin et non visible ou écriture en blanc sur fond blanc), tu mets "0" dans la cellule puis le code ci-dessous :

VB:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
  
     If [A1] = "" Then
            [A1].NumberFormat = "#,##0.00 €"
            [A1] = [V1]
End If: End If
End Sub

Bonne soirée à toutes & à tous
Eric c
 
Dernière édition:

un internaute

XLDnaute Impliqué
Bonjour Eric C
Merci ça fonctionne mais j'en ai plusieurs
Mais cellules sont celles ci-dessous
Çà bug sur Range sinon nickel

VB:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, .Range("G103", "G105", "G107")) Is Nothing Then

     If ["G103", "G105", "G107"] = "" Then
            ["G103", "G105", "G107"].NumberFormat = "#,##0.00 €"
            ["G103", "G105", "G107"] = ["M103", "M105, "M107"]
End If: End If
End Sub
 

un internaute

XLDnaute Impliqué
Oubli guillemets mais ça change rien

VB:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target("G103", "G105", "G107")) Is Nothing Then

     If ["G103", "G105", "G107"] = "" Then
            ["G103", "G105", "G107"].NumberFormat = "#,##0.00 €"
            ["G103", "G105", "G107"] = ["M103", "M105", "M107"]
            
End If: End If
End Sub
 

Eric C

XLDnaute Barbatruc
Bonjour le forum
Bonjour un internaute

Je n'ai pas trop le temps en ce moment. J'ai tenté de bidouiller, en vain, autre chose mais cela ne fonctionne pas.
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cel As Range, rg As Range, isect As Range
Set cel = Cells(ActiveCell.Row, ActiveCell.Column)
Set rg = Range("A1:A5")
'Set rg = Application.Intersect(Target, Range("A1:A5"))
'Set isect = rg

Set isect = Application.Intersect(cel, rg)
If isect = "" Then                  'Is Empty Then 'Nothing Then '= "" Then
isect.NumberFormat = "#,##0.00 €"
isect.Value = [C1]
End If

End Sub
Il y aura bien une âme charitable qui va te venir en aide.

Concernant l'action que tu désires effectuer dans une plage de cellule, il faut utiliser :
Code:
If Not Application.Intersect(Target, Range("A1,A5,A10…"")) Is Nothing Then

Bonne journée à toutes & à tous
Eric c
 

un internaute

XLDnaute Impliqué
Bonjour Eric C
Voilà
Cellule fusionnées
Et les événement dans un autre macro
Un GRAND merci ça fonctionne
VB:
  Application.ScreenUpdating = False
     Range("G103, G105, G107").NumberFormat = "#,##0.00 €"
    Application.EnableEvents = False
    If Not Intersect(Target, Range("G103, G105, G107")) Is Nothing Then
         If Target.Resize(, 1).Value = "" Then Target = "000"
         If Range("G103") = "" And Range("G105") = "" And Range("G107") = "" Then
            Range("G103, G105, G107").NumberFormat = "#,##0.00 €"
            Range("G103, G105, G107") = Range("M103, M105, M107")
        End If
    End If
Sortie:
    Application.EnableEvents = True
Cordialement
 

Discussions similaires

Statistiques des forums

Discussions
312 228
Messages
2 086 417
Membres
103 204
dernier inscrit
alaa20dine01