Remonter texte dans colonne

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

castor30

XLDnaute Occasionnel
Bonjour le forum,
Pouvez-vous m'aider pour que je puisse "remonter" les infos saisies dans une colonne de préférence par Vba.
En vous remerciant.
 

Pièces jointes

Bonjour
1) supprimer les tirets
2) trier

VB:
Sub remonte()
fin = Range("E" & Rows.Count).End(xlUp).Row
Tabloinit = Range("E1:E" & fin).Value
For i = LBound(Tabloinit) To UBound(Tabloinit)
    If Tabloinit(i, 1) = "-" Or Tabloinit(i, 1) = "e_mail" Then
        Tabloinit(i, 1) = ""
    End If
Next i
Range("H1").Resize(fin) = Tabloinit


    ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range("H1"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortTextAsNumbers
    With ActiveWorkbook.Worksheets("Feuil1").Sort
        .SetRange Range("H1:H" & fin)
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

End Sub
 
Bonjour vgendron,
Heureux de te retrouver.
Il y a un problème que j'aurai du préciser, c'est que je dois absolument rester dans la même colonne.
En testant le code, changé H pour E il y a un bug à ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
En te remerciant.
 
Tu as du oublier un remplacement...

ceci fonctionne parfaitement
VB:
Sub remonte()
fin = Range("E" & Rows.Count).End(xlUp).Row
Tabloinit = Range("E1:E" & fin).Value
For i = LBound(Tabloinit) To UBound(Tabloinit)
    If Tabloinit(i, 1) = "-" Or Tabloinit(i, 1) = "e_mail" Then
        Tabloinit(i, 1) = ""
    End If
Next i
Range("E1").Resize(fin) = Tabloinit


    ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range("E1"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortTextAsNumbers
    With ActiveWorkbook.Worksheets("Feuil1").Sort
        .SetRange Range("E1:E" & fin)
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

End Sub
 
et comme je sens que tu vas me dire qu'il faut commencer à la ligne 2 et garder le titre "e_mail"

VB:
Sub remonte()
fin = Range("E" & Rows.Count).End(xlUp).Row
Tabloinit = Range("E2:E" & fin).Value
For i = LBound(Tabloinit) To UBound(Tabloinit)
    If Tabloinit(i, 1) = "-" Then
        Tabloinit(i, 1) = ""
    End If
Next i
Range("E2").Resize(fin - 1) = Tabloinit


    ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range("E2"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortTextAsNumbers
    With ActiveWorkbook.Worksheets("Feuil1").Sort
        .SetRange Range("E2:E" & fin)
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

End Sub
 
Re,
Il y a un problème ici :
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear

viewer.php
http://zupimages.net/viewer.php?id=17/45/j5ks.jpg
 
Avec l'enregistreur c'est OK, mais la longueur de la colonne sera variable
Code :
Sub Macro1()
'
[E2:E87].Select
Selection.Sort Key1:=Range("E2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("E2:E11").Select
Selection.ClearContents
Range("E12:E24").Select
Selection.Cut Destination:=Range("E2:E14")
Range("E2:E14").Select
End Sub
 
d'où la variable "fin"

essaie ceci
VB:
Sub remonte()
fin = Range("E" & Rows.Count).End(xlUp).Row
Tabloinit = Range("E2:E" & fin).Value
For i = LBound(Tabloinit) To UBound(Tabloinit)
    If Tabloinit(i, 1) = "-" Then
        Tabloinit(i, 1) = ""
    End If
Next i
Range("E2").Resize(fin - 1) = Tabloinit

Range("E2").Resize(fin - 1).Select
Selection.Sort Key1:=Range("E2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'
'ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
'ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range("E2"), _
'    SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
'    xlSortTextAsNumbers
'With ActiveWorkbook.Worksheets("Feuil1").Sort
'    .SetRange Range("E2:E" & fin)
'    .Header = xlNo
'    .MatchCase = False
'    .Orientation = xlTopToBottom
'    .SortMethod = xlPinYin
'    .Apply
'End With

End Sub

après. si ca ne marche toujours pas, bah désolé. je ne peux plus rien.. à toi d'adapter le code
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
7
Affichages
210
Réponses
4
Affichages
155
  • Question Question
Microsoft 365 index
Réponses
8
Affichages
282
Réponses
18
Affichages
353
Réponses
3
Affichages
201
Réponses
4
Affichages
290
Retour