ordenar en columna

dragonfire33

Board Regular
Joined
Oct 7, 2021
Messages
52
Office Version
  1. 365
Platform
  1. Windows
como puedo ejecutar este codigo en la columna "UA" y ordenar de acuerdo a sus dos ultimas cifras dante
VBA Code:
Dim valores As New Collection
Sub Ordenar2UltimasCifras()
'Por Dante Amor
'
Set valores = Nothing
Set r = Range("B1:D9")
cfin = r.Columns.Count + r.Cells(1, 1).Column + 1
Columns(cfin).ClearContents
For Each c In r
Call Agregar(c)
Next
'
For i = valores.Count To 1 Step -1
j = j + 1
Cells(j, cfin) = valores(i)
Next
Set r = Nothing
Set valores = Nothing
End Sub
'
Sub Agregar(valor)
'por.Dante Amor
For i = 1 To valores.Count
If Val(Right(valores(i), 2)) < Val(Right(valor, 2)) Then
valores.Add valor, Before:=i
Exit Sub
End If
Next
valores.Add valor
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,216,125
Messages
6,128,998
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top