VBA Excel
Tarik
-
5 mai 2015 à 23:15
Frenchie83 Messages postés 2240 Date d'inscription lundi 6 mai 2013 Statut Membre Dernière intervention 11 août 2023 -
Frenchie83 Messages postés 2240 Date d'inscription lundi 6 mai 2013 Statut Membre Dernière intervention 11 août 2023 -
Bonjour,
J'ai fait une macro qui va chercher des données précises dans un autre fichiers et qui copie la ligne entière.
Ma macro est censée rechercher et copier 3 lignes de données précises dans un autre fichier cependant une fois la macro lancée elle n'applique ce programme qu'a une seule "hypothèse" sur les 3 possible.
Cela se produit aussi bien avec l'instruction IF qu'avec SELECT CASE :
Avec IF
If Range("A" & numeroligne).Value = hypothese1 Then
Range("A" & numeroligne).EntireRow.Copy
Windows("EXPLOIT DATA.xlsm").Activate
Range("A10").PasteSpecial xlPasteAll
End If
If Range("A" & numeroligne).Value = hypothese2 Then
Range("A" & numeroligne).EntireRow.Copy
Windows("EXPLOIT DATA.xlsm").Activate
Range("A11").PasteSpecial xlPasteAll
End If
If Range("A" & numeroligne).Value = hypothese3 Then
Range("A" & numeroligne).EntireRow.Copy
Windows("EXPLOIT DATA.xlsm").Activate
Range("A12").PasteSpecial xlPasteAll
__________________________________________________________
Avec Select Case
Select Case Range("A" & numeroligne)
Case hypothese1
Range("A" & numeroligne).EntireRow.Copy
Sheets("Feuil1").Activate
Range("A10").PasteSpecial xlPasteAll
Case hypothese2
Range("A" & numeroligne).EntireRow.Copy
Sheets("Feuil1").Activate
Range("A11").PasteSpecial xlPasteAll
Case hypothese3
Range("A" & numeroligne).EntireRow.Copy
Sheets("Feuil1").Activate
Range("A12").PasteSpecial xlPasteAll
End Select
End Sub
________________________________________________________
Merci pour votre aide.
Tarik.
J'ai fait une macro qui va chercher des données précises dans un autre fichiers et qui copie la ligne entière.
Ma macro est censée rechercher et copier 3 lignes de données précises dans un autre fichier cependant une fois la macro lancée elle n'applique ce programme qu'a une seule "hypothèse" sur les 3 possible.
Cela se produit aussi bien avec l'instruction IF qu'avec SELECT CASE :
Avec IF
If Range("A" & numeroligne).Value = hypothese1 Then
Range("A" & numeroligne).EntireRow.Copy
Windows("EXPLOIT DATA.xlsm").Activate
Range("A10").PasteSpecial xlPasteAll
End If
If Range("A" & numeroligne).Value = hypothese2 Then
Range("A" & numeroligne).EntireRow.Copy
Windows("EXPLOIT DATA.xlsm").Activate
Range("A11").PasteSpecial xlPasteAll
End If
If Range("A" & numeroligne).Value = hypothese3 Then
Range("A" & numeroligne).EntireRow.Copy
Windows("EXPLOIT DATA.xlsm").Activate
Range("A12").PasteSpecial xlPasteAll
__________________________________________________________
Avec Select Case
Select Case Range("A" & numeroligne)
Case hypothese1
Range("A" & numeroligne).EntireRow.Copy
Sheets("Feuil1").Activate
Range("A10").PasteSpecial xlPasteAll
Case hypothese2
Range("A" & numeroligne).EntireRow.Copy
Sheets("Feuil1").Activate
Range("A11").PasteSpecial xlPasteAll
Case hypothese3
Range("A" & numeroligne).EntireRow.Copy
Sheets("Feuil1").Activate
Range("A12").PasteSpecial xlPasteAll
End Select
End Sub
________________________________________________________
Merci pour votre aide.
Tarik.
A voir également:
- VBA Excel
- Liste déroulante excel - Guide
- Word et excel gratuit - Guide
- Déplacer colonne excel - Guide
- Si ou excel - Guide
- Excel compter cellule couleur sans vba - Guide
1 réponse
Frenchie83
Messages postés
2240
Date d'inscription
lundi 6 mai 2013
Statut
Membre
Dernière intervention
11 août 2023
339
6 mai 2015 à 04:29
6 mai 2015 à 04:29
Bonjour
Remplacez "Sheets("Feuil1").Activate" par "Sheets("Feuil1").Select"
Cdlt
Remplacez "Sheets("Feuil1").Activate" par "Sheets("Feuil1").Select"
Cdlt