Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

inverser l'ordre des lignes apres import

4 réponses
Avatar
pierre.
bonjour

J'importe un fichier avec plusieurs colonnes en txt avec sépararateur ;
La cellule A1 correspond à la premiere ligne du fichier txt et A5000 la
derniere ligne ce qui est un
comportement normal , mais est il possible sous excel d'inverser l'odre.
J'aurais aimé que A1 devient la derniere ligne et A 5000 la premiere ligne.
merci

joyeux noel à tous

Pierre

4 réponses

Avatar
Modeste
Bonsour® pierre. avec ferveur ;o))) vous nous disiez :

J'importe un fichier avec plusieurs colonnes en txt avec sépararateur ; La
cellule A1 correspond à la premiere ligne du fichier txt et A5000
la derniere ligne ce qui est un
comportement normal , mais est il possible sous excel d'inverser
l'odre. J'aurais aimé que A1 devient la derniere ligne et A 5000 la
premiere ligne. merci


Sub Macro1()
'--------------ajouter une colonne
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
'--------------numeroter
ActiveCell.FormulaR1C1 = "1"
Range("A2").Select
ActiveCell.FormulaR1C1 = "2"
Range("A1:A2").Select
Selection.AutoFill Destination:=Range("A1:A5000")
'------------trier
Range("A1:A5000").Select
Range("A1: x5000").Sort Key1:=Range("A2"), Order1:=xlDescending, Header:= _
xlYes, OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'----------supprimer
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
End Sub


--
--
@+
;o)))

Avatar
MichDenis
Sub test1()

Dim Rg As Range
Dim DerLig As Long, DerCol As Integer
Application.ScreenUpdating = False

'Tu dois adapter le nom de la feuille
With Worksheets("Feuil1")
DerLig = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
DerCol = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
Set Rg = .Range(.Cells(1, DerCol + 1), .Cells(DerLig, DerCol + 1))
End With

With Rg
.Formula = "=Row()"
.Value = .Value
With .CurrentRegion
.Sort Rg(1, 1), xlDescending
End With
.Value = ""
End With
End Sub





"pierre." a écrit dans le message de news:
%23j8yu%
bonjour

J'importe un fichier avec plusieurs colonnes en txt avec sépararateur ;
La cellule A1 correspond à la premiere ligne du fichier txt et A5000 la
derniere ligne ce qui est un
comportement normal , mais est il possible sous excel d'inverser l'odre.
J'aurais aimé que A1 devient la derniere ligne et A 5000 la premiere ligne.
merci

joyeux noel à tous

Pierre
Avatar
MichDenis
J'ai apporté une légère amélioration au cas où tu aurais
soit une ligne ou colonne entière de vide dans ton tableau.

Pour les besoins de la cause, j'ai supposé qu'il y avait au moins
une colonne totalement vide à droite du tableau.

'----------------------------------
Sub test1()

Dim Rg As Range
Dim DerCol As Integer, DerLig As Long

Application.ScreenUpdating = False

'Tu dois adapter le nom de la feuille
With Worksheets("Feuil1")
DerLig = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
DerCol = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
Set Rg = .Range(.Cells(1, DerCol + 1), .Cells(DerLig, DerCol + 1))
End With

With Rg
.Formula = "=Row()"
.Value = .Value
With .Offset(, -Rg.Column + 1).Resize(, Rg.Column)
.Sort Rg(1, 1), xlDescending
End With
.Value = ""
End With
End Sub
'----------------------------------



"MichDenis" a écrit dans le message de news:

Sub test1()

Dim Rg As Range
Dim DerLig As Long, DerCol As Integer
Application.ScreenUpdating = False

'Tu dois adapter le nom de la feuille
With Worksheets("Feuil1")
DerLig = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
DerCol = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
Set Rg = .Range(.Cells(1, DerCol + 1), .Cells(DerLig, DerCol + 1))
End With

With Rg
.Formula = "=Row()"
.Value = .Value
With .CurrentRegion
.Sort Rg(1, 1), xlDescending
End With
.Value = ""
End With
End Sub





"pierre." a écrit dans le message de news:
%23j8yu%
bonjour

J'importe un fichier avec plusieurs colonnes en txt avec sépararateur ;
La cellule A1 correspond à la premiere ligne du fichier txt et A5000 la
derniere ligne ce qui est un
comportement normal , mais est il possible sous excel d'inverser l'odre.
J'aurais aimé que A1 devient la derniere ligne et A 5000 la premiere ligne.
merci

joyeux noel à tous

Pierre
Avatar
pierre.
merci à tous les deux, superbe
bonnes fêtes
pierre



"MichDenis" a écrit dans le message de news:

J'ai apporté une légère amélioration au cas où tu aurais
soit une ligne ou colonne entière de vide dans ton tableau.

Pour les besoins de la cause, j'ai supposé qu'il y avait au moins
une colonne totalement vide à droite du tableau.

'----------------------------------
Sub test1()

Dim Rg As Range
Dim DerCol As Integer, DerLig As Long

Application.ScreenUpdating = False

'Tu dois adapter le nom de la feuille
With Worksheets("Feuil1")
DerLig = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
DerCol = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
Set Rg = .Range(.Cells(1, DerCol + 1), .Cells(DerLig, DerCol + 1))
End With

With Rg
.Formula = "=Row()"
.Value = .Value
With .Offset(, -Rg.Column + 1).Resize(, Rg.Column)
.Sort Rg(1, 1), xlDescending
End With
.Value = ""
End With
End Sub
'----------------------------------



"MichDenis" a écrit dans le message de news:

Sub test1()

Dim Rg As Range
Dim DerLig As Long, DerCol As Integer
Application.ScreenUpdating = False

'Tu dois adapter le nom de la feuille
With Worksheets("Feuil1")
DerLig = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
DerCol = .Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
Set Rg = .Range(.Cells(1, DerCol + 1), .Cells(DerLig, DerCol + 1))
End With

With Rg
.Formula = "=Row()"
.Value = .Value
With .CurrentRegion
.Sort Rg(1, 1), xlDescending
End With
.Value = ""
End With
End Sub





"pierre." a écrit dans le message de news:
%23j8yu%
bonjour

J'importe un fichier avec plusieurs colonnes en txt avec sépararateur ;
La cellule A1 correspond à la premiere ligne du fichier txt et A5000 la
derniere ligne ce qui est un
comportement normal , mais est il possible sous excel d'inverser l'odre.
J'aurais aimé que A1 devient la derniere ligne et A 5000 la premiere
ligne.
merci

joyeux noel à tous

Pierre