bonjour a tous
je recois des tableaux d'une dizaine de colonnes qui sont remplies a
l'aide de validation de liste en cascade,plus qq formules, que j'ai
trouver sur le site de jb
colonne" b"en cascade par rapport a ce qui est rentre dans "a"
colonne "d" par rapport au resultat d'une formule inscrite dans "c"
le reste des colonnes simple validation de listes
ces tableaux je les selectionne,les copie ensuite et je les recolle
(collage speciale,uniquement valeur)pour en refaire un tableau de
recap unique dans un autre classeur
dans ce classeur j'utilise une macro qui recherche un element du
tableau et m'affiche les resultats ;mon probleme c'est qu'elle ne
trouve pas les donnees d'une colonne "d"; alors que si j'efface les
elements recopier dans "d" et que je les retape manuellement la macro
les trouve
je pense a un probleme de format quel serait le probleme
qu'elle solution? auriez vous un code permettant de tout mettre au
format texte? visible par cette macro
je suis sous excel 2003 et xp
ci dessous la macro de recherche
je vous remercie d'avance pour votre aide
Sub Traitement()
Dim aRes As Variant, aRng As Range, nRow&, nCol%
Dim NOM$
Dim tableau As Variant
Dim i&, j&, k&
NOM$ =3D InputBox(prompt:=3D"Tapez un nom", _
Title:=3D"RECHERCHER UN PERSONNAGE;UN LIEU;UN EVENEMENT")
If NOM$ =3D "" Then Exit Sub
tableau =3D Sheets("ma base").UsedRange
Set aRng =3D Sheets("ma base").UsedRange
nRow =3D aRng.Rows.Count
nCol =3D aRng.Columns.Count
With Sheets("mon r=E9sultat")
.Range("A1").CurrentRegion.ClearContents
.Range("A1").CurrentRegion.ClearFormats
.Range("A1").Value =3D NOM$ & " est introuvable"
k =3D 1
For i =3D 1 To nRow
For j =3D 3 To nCol
If UCase(NOM$) =3D UCase(tableau(i, j)) Then
Range(aRng.Cells(i, 1), aRng.Cells(i, nCol)).Copy _
Destination:=3D.Cells(k, 1)
k =3D k + 1
Exit For
End If
Next j
Next i
End With
Application.DisplayAlerts =3D True
Application.ScreenUpdating =3D True
Sheets("mon r=E9sultat").Select
userform2.Hide
End Sub
NOM$ = InputBox(prompt:="Tapez un nom", _ Title:="RECHERCHER UN PERSONNAGE;UN LIEU;UN EVENEMENT") If NOM$ = "" Then Exit Sub Set aRng = Sheets("ma base").UsedRange tableau = aRng nRow = aRng.Rows.Count nCol = aRng.Columns.Count
With Sheets("mon résultat") .Range("A1").CurrentRegion.ClearContents .Range("A1").CurrentRegion.ClearFormats .Range("A1").Value = NOM$ & " est introuvable"
k = 1 For i = 1 To nRow For j = 3 To nCol + 2 'modification pmo If UCase(NOM$) = UCase(tableau(i, j - 2)) Then 'modification pmo Range(aRng.Cells(i, 1), aRng.Cells(i, nCol)).Copy _ Destination:=.Cells(k, 1) k = k + 1 Exit For End If Next j Next i
End With
Application.DisplayAlerts = True Application.ScreenUpdating = True Sheets("mon résultat").Select userform2.Hide End Sub '**********************
Cordialement.
PMO Patrick Morange
Bonjour,
Essayez avec ce code modifié
'*****************
Sub Traitement()
Dim aRes As Variant, aRng As Range, nRow&, nCol%
Dim NOM$
Dim tableau As Variant
Dim i&, j&, k&
NOM$ = InputBox(prompt:="Tapez un nom", _
Title:="RECHERCHER UN PERSONNAGE;UN LIEU;UN EVENEMENT")
If NOM$ = "" Then Exit Sub
Set aRng = Sheets("ma base").UsedRange
tableau = aRng
nRow = aRng.Rows.Count
nCol = aRng.Columns.Count
With Sheets("mon résultat")
.Range("A1").CurrentRegion.ClearContents
.Range("A1").CurrentRegion.ClearFormats
.Range("A1").Value = NOM$ & " est introuvable"
k = 1
For i = 1 To nRow
For j = 3 To nCol + 2 'modification pmo
If UCase(NOM$) = UCase(tableau(i, j - 2)) Then 'modification pmo
Range(aRng.Cells(i, 1), aRng.Cells(i, nCol)).Copy _
Destination:=.Cells(k, 1)
k = k + 1
Exit For
End If
Next j
Next i
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Sheets("mon résultat").Select
userform2.Hide
End Sub
'**********************
NOM$ = InputBox(prompt:="Tapez un nom", _ Title:="RECHERCHER UN PERSONNAGE;UN LIEU;UN EVENEMENT") If NOM$ = "" Then Exit Sub Set aRng = Sheets("ma base").UsedRange tableau = aRng nRow = aRng.Rows.Count nCol = aRng.Columns.Count
With Sheets("mon résultat") .Range("A1").CurrentRegion.ClearContents .Range("A1").CurrentRegion.ClearFormats .Range("A1").Value = NOM$ & " est introuvable"
k = 1 For i = 1 To nRow For j = 3 To nCol + 2 'modification pmo If UCase(NOM$) = UCase(tableau(i, j - 2)) Then 'modification pmo Range(aRng.Cells(i, 1), aRng.Cells(i, nCol)).Copy _ Destination:=.Cells(k, 1) k = k + 1 Exit For End If Next j Next i
End With
Application.DisplayAlerts = True Application.ScreenUpdating = True Sheets("mon résultat").Select userform2.Hide End Sub '**********************