miguelangelo
XLDnaute Occasionnel
Bonjour,
Je suis un nouveau sur votre site, qui chaque jour me donne envie de m'interesser un peu plus aux macros.
(si je loupe une une facon d'exposer mon probleme ou que je m'exprime mal, n'hesitez pas à me le faire savoir )
Voilà,
j'ai retrouvé une fonction recherche dans le site :
Sub Recher_articles()
Dim MonString As String, FoundCell As Range, Adr As String
Dim LeString As Variant, Compteur As Long, Pos As Integer
MonString = InputBox(Prompt:= _
"Chaîne recherchée.", _
Title:="Rechercher et Remplacer")
If MonString = "" Then Exit Sub
With ActiveSheet
Set FoundCell = .Cells.Find(What:=MonString, _
LookIn:=xlValues, LookAt:=xlPart)
If Not FoundCell Is Nothing Then
Adr = FoundCell.Address
Do
Do
Pos = Pos + 1
Pos = InStr(Pos, FoundCell, MonString, vbTextCompare)
If Pos <> 0 Then Compteur = Compteur + 1
Loop Until Pos = 0
FoundCell.EntireRow.Select
reponse = MsgBox("Est ce cette ligne", vbYesNo, "Question")
If reponse = 7 Then
GoTo Suivant
End If
Selection.Copy
Sheets("Sheet2").Select
Range("A1").End(xlDown).Offset(1, 0).Select
ActiveCell.EntireRow.PasteSpecial
Sheets("Sheet1").Select
Application.CutCopyMode = False
Suivant:
FoundCell.Select
Set FoundCell = .Cells.FindNext(After:=FoundCell)
If FoundCell Is Nothing Then Exit Do
If FoundCell.Address = Range(Adr).Address Then Exit Do
Loop While Not FoundCell Is Nothing
End If
End With
Set FoundCell = Nothing
End Sub
la 1ere partie m'interesse. Ce qui ne va plus, c'est que quand il aura trouvé l'information monstring, je voudrais qu'il aille copier la valeur qui se trouve dans la colonne A.
ex :
colonne A ------- B ----------c--------------------------d
----2315---------103---30134058403214---32, CHEMIN DU VIEUX MOULIN
que je fasse une recherche sur "103" il me copiera 2315, que je demande "moulin" --> 2315 (tout cela pour coller ailleurs).
merci à vous
Truly newbee...
Je suis un nouveau sur votre site, qui chaque jour me donne envie de m'interesser un peu plus aux macros.
(si je loupe une une facon d'exposer mon probleme ou que je m'exprime mal, n'hesitez pas à me le faire savoir )
Voilà,
j'ai retrouvé une fonction recherche dans le site :
Sub Recher_articles()
Dim MonString As String, FoundCell As Range, Adr As String
Dim LeString As Variant, Compteur As Long, Pos As Integer
MonString = InputBox(Prompt:= _
"Chaîne recherchée.", _
Title:="Rechercher et Remplacer")
If MonString = "" Then Exit Sub
With ActiveSheet
Set FoundCell = .Cells.Find(What:=MonString, _
LookIn:=xlValues, LookAt:=xlPart)
If Not FoundCell Is Nothing Then
Adr = FoundCell.Address
Do
Do
Pos = Pos + 1
Pos = InStr(Pos, FoundCell, MonString, vbTextCompare)
If Pos <> 0 Then Compteur = Compteur + 1
Loop Until Pos = 0
FoundCell.EntireRow.Select
reponse = MsgBox("Est ce cette ligne", vbYesNo, "Question")
If reponse = 7 Then
GoTo Suivant
End If
Selection.Copy
Sheets("Sheet2").Select
Range("A1").End(xlDown).Offset(1, 0).Select
ActiveCell.EntireRow.PasteSpecial
Sheets("Sheet1").Select
Application.CutCopyMode = False
Suivant:
FoundCell.Select
Set FoundCell = .Cells.FindNext(After:=FoundCell)
If FoundCell Is Nothing Then Exit Do
If FoundCell.Address = Range(Adr).Address Then Exit Do
Loop While Not FoundCell Is Nothing
End If
End With
Set FoundCell = Nothing
End Sub
la 1ere partie m'interesse. Ce qui ne va plus, c'est que quand il aura trouvé l'information monstring, je voudrais qu'il aille copier la valeur qui se trouve dans la colonne A.
ex :
colonne A ------- B ----------c--------------------------d
----2315---------103---30134058403214---32, CHEMIN DU VIEUX MOULIN
que je fasse une recherche sur "103" il me copiera 2315, que je demande "moulin" --> 2315 (tout cela pour coller ailleurs).
merci à vous
Truly newbee...
Dernière édition: