Recherche et report

zefirstfan

XLDnaute Junior
Bonjour, Je bloque sur une recherche dans une table.
Les explications se trouvent sur le fichier joint.
Merci par avance de votre aide.
Zefirstfan
 

Pièces jointes

  • Excel download.xlsx
    12.4 KB · Affichages: 42
  • Excel download.xlsx
    12.4 KB · Affichages: 48
  • Excel download.xlsx
    12.4 KB · Affichages: 53

DoubleZero

XLDnaute Barbatruc
Re : Recherche et report

Bonjour, zefirstfan, le Forum,

Un essai avec ce code, logé dans le module de l'onglet "Rapport".

VB:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo fin
    If Target.Address = "$B$1" Then Sheets("Table").Rows("1:1").Find(what:=Sheets("Rapport"). _
      [b1]).Offset(1, 0).Resize(5, 1).Copy Destination:=Sheets("Rapport").[b3]
    Target.Select
    Exit Sub
fin:
    MsgBox ("Date non inscrite dans l'onglet ""Table"".")
    Target = ""
End Sub

A bientôt :)

P. S. : Bonjour, mapomme :)
 
Dernière édition:

mapomme

XLDnaute Barbatruc
Supporter XLD
Re : Recherche et report

Bonjour zefirstfan, DoubleZero,

Avec une formule en B3 à tirer vers le bas:
Code:
=SI(RECHERCHEV(A3;Table!$A$1:$F$6;EQUIV($B$1;Table!$A$1:$F$1;0);FAUX)="";"";RECHERCHEV(A3;Table!$A$1:$F$6;EQUIV($B$1;Table!$A$1:$F$1;0);FAUX))
 

Pièces jointes

  • zefirstfan-recherche v1.xlsx
    12.4 KB · Affichages: 36

zefirstfan

XLDnaute Junior
Re : Recherche et report

Bonjour,
J'ai essaye et j'ai pris l'option VBA qui correspond mieux a mon fichier final. Merci a DoubleZero et a MaPomme pour la contribution.
J'ai ajoute une 2eme partie de code pour gerer un user form.
Un double click sur une cellule de la feuille Table ouvre un usf avec diverses information.
Le 2 fonctions tournent tres bien separement, par contre, si je lance l'usf, je me retrouve avec l'erreur "Date non insrcite dans table".
Je ne peux pas envoyer le fichier car j'ai des infos confidentielles, par contre les differentes lignes de codes sont ci dessous:
'Sur feuille Rapport
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo fin
If Target.Address = "$B$1" Then Sheets("Table").Rows("1:1").Find(what:=Sheets("Rapport"). _
[b1]).Offset(1, 0).Resize(348, 1).Copy Destination:=Sheets("Rapport").[b3]
Target.Select
Exit Sub
fin:
MsgBox ("Date non inscrite dans l'onglet ""Table"".")
Target = ""
End Sub

'Sur feuille table
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Application.Intersect(Target, Range("B2:BP349")) Is Nothing Then
Cancel = True
UserForm1.Show
End If
End Sub


'Sur l'Userform
Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub


Private Sub UserForm_Initialize()
Me.TextBox1.Text = ActiveCell.Value
End Sub

Private Sub TextBox1_Change()
Dim Cel As Range
Dim Ligne As Long
Dim I As Integer
For I = 2 To 7
Me.Controls("TextBox" & I) = ""
Next I
With Sheets("BDD")
Set Cel = .Columns("A").Find(what:=Me.TextBox1, LookIn:=xlValues, lookat:=xlWhole)
If Not Cel Is Nothing Then
For I = 2 To 7
Me.Controls("TextBox" & I) = .Cells(Cel.Row, I)
Next I
End If
End With
End Sub

Merci de votre aide pour debusquer l'erreur.
A plus
Zefirstfan
 

Discussions similaires

Statistiques des forums

Discussions
312 488
Messages
2 088 847
Membres
103 972
dernier inscrit
steeter