OVH Cloud OVH Cloud

Macro

10 réponses
Avatar
Sebastien
Bonjour
j'ai 2 feuille dans mon classeur feuil1 et feuil2 dans ma feuille 1 j'ai 4
numero A1=1 A2= 2 A3= 3 A4= 4 je veux a l'aide d'un bouton qu'il me
recherche le numero sur laquelle je suis positionner ex: je suis sur la
cellule A2 qui est le numero 2 donc en appuyant sur le bouton il va dans ma
feuil2 et il me selectionne le chiffre 2...aussi simple que sa !
j'ai fait une batterie de test avec activecell....... mais sa fonctionne
jamais
quelqu'un peut m'aider svp ?
merci

10 réponses

Avatar
isabelle
bonjour Sebastien,

le numéros de 1 à 4 peuvent t'ils être n'importe ou sur la feuil2 ou bien dans une colonne spécifique ?

isabelle


Bonjour
j'ai 2 feuille dans mon classeur feuil1 et feuil2 dans ma feuille 1 j'ai 4
numero A1=1 A2= 2 A3= 3 A4= 4 je veux a l'aide d'un bouton qu'il me
recherche le numero sur laquelle je suis positionner ex: je suis sur la
cellule A2 qui est le numero 2 donc en appuyant sur le bouton il va dans ma
feuil2 et il me selectionne le chiffre 2...aussi simple que sa !
j'ai fait une batterie de test avec activecell....... mais sa fonctionne
jamais
quelqu'un peut m'aider svp ?
merci




Avatar
Sebastien
n'importe ou !!!
Avatar
isabelle
s'il y a plus d'un chiffre 2 sur la feuille 2, elle ira au premier numéro rencontré,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub


isabelle


n'importe ou !!!




Avatar
isabelle
correction,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil" & [Target]).Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub

isabelle


s'il y a plus d'un chiffre 2 sur la feuille 2, elle ira au premier
numéro rencontré,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub


isabelle


n'importe ou !!!





Avatar
Sebastien
Sa ne semble pas fonctionner :(
mais je croi que je me suis peut-etre mal exprimer. Exemple je selectionne
la cellule A4 (A4 = 4) et je vais cliquer sur mon boutton automatiquement il
va me selectionner le numero 4 dans la feuil2
( recherche moi la cellelule active de la feuil1 dans ma feuil2 quelque
chose comme sa !!! )




"isabelle" a écrit dans le message de news:

correction,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil" & [Target]).Cells.Find(What:=[Target],
After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub

isabelle


s'il y a plus d'un chiffre 2 sur la feuille 2, elle ira au premier numéro
rencontré,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub


isabelle


n'importe ou !!!







Avatar
isabelle
comme ça,

Private Sub CommandButton1_Click()
Set Target = ActiveCell
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil2").Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil2").Range(addr)
End If
End Sub

isabelle

Sa ne semble pas fonctionner :(
mais je croi que je me suis peut-etre mal exprimer. Exemple je selectionne
la cellule A4 (A4 = 4) et je vais cliquer sur mon boutton automatiquement il
va me selectionner le numero 4 dans la feuil2
( recherche moi la cellelule active de la feuil1 dans ma feuil2 quelque
chose comme sa !!! )




"isabelle" a écrit dans le message de news:


correction,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil" & [Target]).Cells.Find(What:=[Target],
After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub

isabelle



s'il y a plus d'un chiffre 2 sur la feuille 2, elle ira au premier numéro
rencontré,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub


isabelle



n'importe ou !!!












Avatar
Sebastien
Excellent sa fonctionnne super bien mais ya pas un moyen de le faire avec un
bouton personnaliser ... affecter une macro. car la je suis oubliger
d'utiliserla bare d'outli visual basic et un bouton vb .... mais ce que je
veux c'est avec un bouton personnaliser en haut genre le petit bonhomme
sourire jaune :)
je ses que je suis demandan mais c'est asser important
merci Isabelle.

"isabelle" a écrit dans le message de news:

comme ça,

Private Sub CommandButton1_Click()
Set Target = ActiveCell
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil2").Cells.Find(What:=[Target], After:¬tiveCell,
LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil2").Range(addr)
End If
End Sub

isabelle

Sa ne semble pas fonctionner :(
mais je croi que je me suis peut-etre mal exprimer. Exemple je
selectionne la cellule A4 (A4 = 4) et je vais cliquer sur mon boutton
automatiquement il va me selectionner le numero 4 dans la feuil2
( recherche moi la cellelule active de la feuil1 dans ma feuil2 quelque
chose comme sa !!! )




"isabelle" a écrit dans le message de news:


correction,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil" & [Target]).Cells.Find(What:=[Target],
After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub

isabelle



s'il y a plus d'un chiffre 2 sur la feuille 2, elle ira au premier
numéro rencontré,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub


isabelle



n'importe ou !!!













Avatar
isabelle
si si, tu peut nommer la macro comme tu veut et l'affecter au bouton de ton choix,

Sub mon_Bouton_Perso()
Set Target = ActiveCell
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil2").Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil2").Range(addr)
End If
End Sub

isabelle

Excellent sa fonctionnne super bien mais ya pas un moyen de le faire avec un
bouton personnaliser ... affecter une macro. car la je suis oubliger
d'utiliserla bare d'outli visual basic et un bouton vb .... mais ce que je
veux c'est avec un bouton personnaliser en haut genre le petit bonhomme
sourire jaune :)
je ses que je suis demandan mais c'est asser important
merci Isabelle.

"isabelle" a écrit dans le message de news:


comme ça,

Private Sub CommandButton1_Click()
Set Target = ActiveCell
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil2").Cells.Find(What:=[Target], After:¬tiveCell,
LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil2").Range(addr)
End If
End Sub

isabelle


Sa ne semble pas fonctionner :(
mais je croi que je me suis peut-etre mal exprimer. Exemple je
selectionne la cellule A4 (A4 = 4) et je vais cliquer sur mon boutton
automatiquement il va me selectionner le numero 4 dans la feuil2
( recherche moi la cellelule active de la feuil1 dans ma feuil2 quelque
chose comme sa !!! )




"isabelle" a écrit dans le message de news:



correction,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil" & [Target]).Cells.Find(What:=[Target],
After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub

isabelle




s'il y a plus d'un chiffre 2 sur la feuille 2, elle ira au premier
numéro rencontré,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub


isabelle




n'importe ou !!!
















Avatar
Sebastien
Ok j'ai tout comprit :)
sa fonctionne comme je le voulait .... c'est juste que si mon nombre existe
pas il me fait un erreur au lieu de rien faire du tout mais je vais vivre
avec !
Merci encord

"isabelle" a écrit dans le message de news:

si si, tu peut nommer la macro comme tu veut et l'affecter au bouton de
ton choix,

Sub mon_Bouton_Perso()
Set Target = ActiveCell
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil2").Cells.Find(What:=[Target], After:¬tiveCell,
LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil2").Range(addr)
End If
End Sub

isabelle

Excellent sa fonctionnne super bien mais ya pas un moyen de le faire avec
un bouton personnaliser ... affecter une macro. car la je suis oubliger
d'utiliserla bare d'outli visual basic et un bouton vb .... mais ce que
je veux c'est avec un bouton personnaliser en haut genre le petit
bonhomme sourire jaune :)
je ses que je suis demandan mais c'est asser important
merci Isabelle.

"isabelle" a écrit dans le message de news:


comme ça,

Private Sub CommandButton1_Click()
Set Target = ActiveCell
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil2").Cells.Find(What:=[Target], After:¬tiveCell,
LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil2").Range(addr)
End If
End Sub

isabelle


Sa ne semble pas fonctionner :(
mais je croi que je me suis peut-etre mal exprimer. Exemple je
selectionne la cellule A4 (A4 = 4) et je vais cliquer sur mon boutton
automatiquement il va me selectionner le numero 4 dans la feuil2
( recherche moi la cellelule active de la feuil1 dans ma feuil2 quelque
chose comme sa !!! )




"isabelle" a écrit dans le message de news:



correction,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil" & [Target]).Cells.Find(What:=[Target],
After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub

isabelle




s'il y a plus d'un chiffre 2 sur la feuille 2, elle ira au premier
numéro rencontré,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Cells.Find(What:=[Target], After:¬tiveCell,
LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub


isabelle




n'importe ou !!!


















Avatar
isabelle
ha ben, on va corriger ça,

Sub mon_Bouton_Perso()
Set Target = ActiveCell
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
On Error Resume Next
addr = Sheets("Feuil2").Cells.Find(What:=[Target], After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:úlse _
, SearchFormat:úlse).Address
If Not addr = Empty Then
Application.Goto Sheets("Feuil2").Range(addr)
Else
MsgBox "valeur non trouvé"
End If
End If
End Sub

isabelle


Ok j'ai tout comprit :)
sa fonctionne comme je le voulait .... c'est juste que si mon nombre existe
pas il me fait un erreur au lieu de rien faire du tout mais je vais vivre
avec !
Merci encord

"isabelle" a écrit dans le message de news:


si si, tu peut nommer la macro comme tu veut et l'affecter au bouton de
ton choix,

Sub mon_Bouton_Perso()
Set Target = ActiveCell
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil2").Cells.Find(What:=[Target], After:¬tiveCell,
LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil2").Range(addr)
End If
End Sub

isabelle


Excellent sa fonctionnne super bien mais ya pas un moyen de le faire avec
un bouton personnaliser ... affecter une macro. car la je suis oubliger
d'utiliserla bare d'outli visual basic et un bouton vb .... mais ce que
je veux c'est avec un bouton personnaliser en haut genre le petit
bonhomme sourire jaune :)
je ses que je suis demandan mais c'est asser important
merci Isabelle.

"isabelle" a écrit dans le message de news:



comme ça,

Private Sub CommandButton1_Click()
Set Target = ActiveCell
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil2").Cells.Find(What:=[Target], After:¬tiveCell,
LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil2").Range(addr)
End If
End Sub

isabelle



Sa ne semble pas fonctionner :(
mais je croi que je me suis peut-etre mal exprimer. Exemple je
selectionne la cellule A4 (A4 = 4) et je vais cliquer sur mon boutton
automatiquement il va me selectionner le numero 4 dans la feuil2
( recherche moi la cellelule active de la feuil1 dans ma feuil2 quelque
chose comme sa !!! )




"isabelle" a écrit dans le message de news:




correction,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Sheets("Feuil" & [Target]).Cells.Find(What:=[Target],
After:¬tiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub

isabelle





s'il y a plus d'un chiffre 2 sur la feuille 2, elle ira au premier
numéro rencontré,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ints = Application.Intersect(Target, Range("A1:A4"))
If Not ints Is Nothing Then
addr = Cells.Find(What:=[Target], After:¬tiveCell,
LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:úlse _
, SearchFormat:úlse).Address
Application.Goto Sheets("Feuil" & [Target]).Range(addr)
End If
End Sub


isabelle





n'importe ou !!!