Microsoft 365 Afficher dans la feuille active la cellule de la Feuille "Appels" qui est à droite de sa cellule active

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour à toutes et à tous,
Je vous souhaite un bon match et une bonne fin de journée :)

Je bute encore sur un code que je ne parviens pas à faire :

Dans ma feuille active cellule "E13", j'ai besoin que le code m'affiche la cellule de la Feuille "Appels" qui est à droite de sa cellule active

Dans mon exemple, "G6" est la cellule active feuille "Appels" et je voudrais comme résultat en Feuil1 "Bonjour le Forum et ALLEZ LES BLEUS"

J'ai des recherches et un tas de tests mais je n'y arrive pas :mad:
Auriez-vous le bon code ,
En cas, je joins un p'tit fichier test.

Je vous remercie vraiment et je continue mes recherches.
Amicalement,
lionel :)
 

Pièces jointes

  • code_test2.xlsm
    19 KB · Affichages: 7
Solution
Bonjour Lionel

Comme cela ça ira mieux
VB:
Private Sub Worksheet_SelectionChange(ByVal R As Range)
If Not Intersect(R, Range("e13")) Is Nothing Then
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    [a1] = ""
    [e13] = ""
    Sheets("Appels").Activate
    toprint = ActiveCell.Offset(0, 1)
    Sheets("Feuil1").Activate
    ActiveCell = toprint
    
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    
    If MsgBox("RdV possible ?" & Chr(10) & Chr(10) & "Si Répondeur et appel avant = RdV possible, répondre OUI" & Chr(10) & Chr(10) & "Clic : OUI   ou    NON", vbQuestion + vbYesNo) <> vbNo Then
        Sheets("Feuil1").Range("a1") = "Rappel RdV"
    End If
    [a1].Select
End If
End...

vgendron

XLDnaute Barbatruc
hello
pas sur de pouvoir acceder à la cellule "active" d'une feuille qui ne l'est pas...
en contournant le pb..
VB:
Private Sub Worksheet_SelectionChange(ByVal R As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
If Not Intersect(R, Range("e13")) Is Nothing Then
    Sheets("Appels").Activate
    toprint = ActiveCell.Offset(0, 1)
    Sheets("Feuil1").Activate
    ActiveCell = toprint
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
 

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonsoir vgendron, le Forum,

J'ai un problème que je n'avais pas prévu :mad:
voici le code :
VB:
Private Sub Worksheet_SelectionChange(ByVal R As Range)
    If Not Intersect(R, Range("e13")) Is Nothing Then
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    [a1] = ""
    [e13] = ""
    Sheets("Appels").Activate
    toprint = ActiveCell.Offset(0, 1)
    Sheets("Feuil1").Activate
    ActiveCell = toprint

        If MsgBox("RdV possible ?" & Chr(10) & Chr(10) & "Si Répondeur et appel avant = RdV possible, répondre  OUI" & Chr(10) & Chr(10) & "Clic : OUI   ou    NON", vbQuestion + vbYesNo) <> vbNo Then
        Sheets("Feuil1").Range("a1") = "Rappel RdV"
        End If
        [a1].Select
        Application.EnableEvents = True
        Application.ScreenUpdating = True
        End If
End Sub

Avant l'exécution du code ci-dessous, J'ai besoin de voir le texte de la cellule de la Feuille "Appels" qui est à droite de sa cellule active.
Code:
If MsgBox("RdV possible ?" & Chr(10) & Chr(10) & "Si Répondeur et appel avant = RdV possible, répondre OUI" & Chr(10) & Chr(10) & "Clic : OUI   ou    NON", vbQuestion + vbYesNo) <> vbNo Then
        Sheets("Feuil1").Range("a1") = "Rappel RdV"
End If

- Quand j'exécute pas à pas, c'est bon.
- Quand je lance la macro en cliquant cellule "E13", ça ne fonctionne pas, le code s'exécute avant la 1ère partie.

Je n'arrive pas à comprendre.
Pourriez-vous m'aider ?
Je joins le fichier test.
Un grand merci,
lionel,
 

Pièces jointes

  • code_test3.xlsm
    20.3 KB · Affichages: 2
Dernière édition:

Phil69970

XLDnaute Barbatruc
Bonjour Lionel

Comme cela ça ira mieux
VB:
Private Sub Worksheet_SelectionChange(ByVal R As Range)
If Not Intersect(R, Range("e13")) Is Nothing Then
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    [a1] = ""
    [e13] = ""
    Sheets("Appels").Activate
    toprint = ActiveCell.Offset(0, 1)
    Sheets("Feuil1").Activate
    ActiveCell = toprint
    
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    
    If MsgBox("RdV possible ?" & Chr(10) & Chr(10) & "Si Répondeur et appel avant = RdV possible, répondre OUI" & Chr(10) & Chr(10) & "Clic : OUI   ou    NON", vbQuestion + vbYesNo) <> vbNo Then
        Sheets("Feuil1").Range("a1") = "Rappel RdV"
    End If
    [a1].Select
End If
End Sub
@Phil69970
 

Discussions similaires

Statistiques des forums

Discussions
311 720
Messages
2 081 886
Membres
101 830
dernier inscrit
sonia poulaert