La siguiente macro me permite ordenar datos segun el apellido paterno, lo que quisiera saber es como hacer para aumentar mayor ordenes, por ejemplo que ahora ordene como el apellido materno, como lo adinaria
Sub macro22()
If [L2] = "ascendente" And [L5] = "Paterno" Then
For x = 2 To 40
For y = x + 1 To 41
If Cells(x, "E") > Cells(y, "E") Then
Variable = Cells(x, "E")
Cells(x, "E") = Cells(y, "E")
Cells(y, "E") = Variable
Variablea = Cells(x, "F")
Cells(x, "F") = Cells(y, "F")
Cells(y, "F") = Variablea
Variableb = Cells(x, "G")
Cells(x, "G") = Cells(y, "G")
Cells(y, "G") = Variableb
Variablec = Cells(x, "H")
Cells(x, "H") = Cells(y, "H")
Cells(y, "H") = Variablec
End If
Next
Next
Else
For x = 2 To 40
For y = x + 1 To 41
If Cells(x, "E") < Cells(y, "E") Then
Variable = Cells(x, "E")
Cells(x, "E") = Cells(y, "E")
Cells(y, "E") = Variable
Variablea = Cells(x, "F")
Cells(x, "F") = Cells(y, "F")
Cells(y, "F") = Variablea
Variableb = Cells(x, "G")
Cells(x, "G") = Cells(y, "G")
Cells(y, "G") = Variableb
Variablec = Cells(x, "H")
Cells(x, "H") = Cells(y, "H")
Cells(y, "H") = Variablec
End If
Next
Next
End If
End Sub
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
La siguiente macro me permite ordenar datos segun el apellido paterno, lo que quisiera saber es como hacer para aumentar mayor ordenes, por ejemplo que ahora ordene como el apellido materno, como lo adinaria
Sub macro22()
If [L2] = "ascendente" And [L5] = "Paterno" Then
For x = 2 To 40
For y = x + 1 To 41
If Cells(x, "E") > Cells(y, "E") Then
Variable = Cells(x, "E")
Cells(x, "E") = Cells(y, "E")
Cells(y, "E") = Variable
Variablea = Cells(x, "F")
Cells(x, "F") = Cells(y, "F")
Cells(y, "F") = Variablea
Variableb = Cells(x, "G")
Cells(x, "G") = Cells(y, "G")
Cells(y, "G") = Variableb
Variablec = Cells(x, "H")
Cells(x, "H") = Cells(y, "H")
Cells(y, "H") = Variablec
End If
Next
Next
Else
For x = 2 To 40
For y = x + 1 To 41
If Cells(x, "E") < Cells(y, "E") Then
Variable = Cells(x, "E")
Cells(x, "E") = Cells(y, "E")
Cells(y, "E") = Variable
Variablea = Cells(x, "F")
Cells(x, "F") = Cells(y, "F")
Cells(y, "F") = Variablea
Variableb = Cells(x, "G")
Cells(x, "G") = Cells(y, "G")
Cells(y, "G") = Variableb
Variablec = Cells(x, "H")
Cells(x, "H") = Cells(y, "H")
Cells(y, "H") = Variablec
End If
Next
Next
End If
End Sub