Microsoft 365 Copier coller une cellule avant qu'elle ne soit modifiée par Sub Worksheet_Change(ByVal Target As Range)

  • Initiateur de la discussion Initiateur de la discussion pat66
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

pat66

XLDnaute Impliqué
Bonjour le forum,

avec la procédure Sub Worksheet_Change(ByVal Target As Range), existe t'il un moyen de copier une valeur avant qu'elle ne soit modifiée par Sub Worksheet_Change(ByVal Target As Range) et coller cette valeur dans une autre cellule

merci
 
Dernière édition:
Solution
Je vous donne encore ça, et je m'arrête là.
VB:
Option Explicit
Private SvgVal
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   If Target.Address <> "$BV$28" Then Exit Sub
   If IsEmpty(Target.Value) Then SvgVal = Me.[AN33].Value Else SvgVal = Null
   End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.Address <> "$BV$28" Or IsEmpty(Target.Value) Or IsNull(SvgVal) Then Exit Sub
   Me.[AO25:AO27].Value = SvgVal
   End Sub
Je vous donne encore ça, et je m'arrête là.
VB:
Option Explicit
Private SvgVal
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   If Target.Address <> "$BV$28" Then Exit Sub
   If IsEmpty(Target.Value) Then SvgVal = Me.[AN33].Value Else SvgVal = Null
   End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.Address <> "$BV$28" Or IsEmpty(Target.Value) Or IsNull(SvgVal) Then Exit Sub
   Me.[AO25:AO27].Value = SvgVal
   End Sub
 
re,

désolé de vous solliciter encore une fois et je vous promets c'est la dernière fois pour pour ce problème, mais je viens de m'apercevoir que AN33 ne sera pas toujours la cellule qui doit être copiée, pourriez vous adapter votre solution avec rechercheV, j'ai bien essayé de remplacer :
If IsEmpty(Target.Value) Then SvgVal = Me.[AN33].Value Else SvgVal = Null
par :
If IsEmpty(Target.Value) Then SvgVal = Me.[FormulaLocal = "=RECHERCHEV(AG$23;D$25:AN$49;37;0)"] Else SvgVal = Null

merci d'avance

VB:
Option Explicit 
Private SvgVal
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   If Target.Address <> "$BV$28" Then Exit Sub
   If IsEmpty(Target.Value) Then SvgVal = Me.[FormulaLocal = "=RECHERCHEV(AG$23;D$25:AN$49;37;0)"] Else SvgVal = Null
   End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.Address <> "$BV$28" Or IsEmpty(Target.Value) Or IsNull(SvgVal) Then Exit Sub
   Me.[AO25:AO27].Value = SvgVal
   End Sub
 
Essayez comme ça si la valeur vous suffit :
VB:
Option Explicit
Private SvgVal
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   If Target.Address <> "$BV$28" Then Exit Sub
   If IsEmpty(Target.Value) Then SvgVal = WorksheetFunction.VLookup(Me.[AG23], _
      Me.[D25:AN49], 37, 0) Else SvgVal = Null
   End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.Address <> "$BV$28" Or IsEmpty(Target.Value) Or IsNull(SvgVal) Then Exit Sub
   Me.[AO25:AO27].Value = SvgVal
   End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
250
  • Question Question
Microsoft 365 Probléme VBA
Réponses
8
Affichages
233
Réponses
4
Affichages
507
Retour