![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
06/11/2008, 21:55
|
![Avatar de mrocf](http://static.forosdelweb.com/customavatars/avatar174421_2.gif) | | | Fecha de Ingreso: marzo-2007 Ubicación: Bs.As.
Mensajes: 1.103
Antigüedad: 17 años, 10 meses Puntos: 88 | |
Respuesta: Ordenar datos alfanumericos excel/access Hola! caesar
El siguiente código te puede resulta útil pues unifica el formato del alfanumérico, quitando todo caracter innecesario:
Código:
Sub UnificarFormato()
Dim Rng As Range, Celda As Range, p As Integer, ii As Integer
On Error Resume Next
Set Rng = Application.InputBox("Seleccione el rango a procesar", Type:=8)
On Error GoTo 0
If Rng Is Nothing Then Exit Sub
Application.ScreenUpdating = False
With Rng
.Value = Evaluate("transpose(transpose(substitute(substitute(substitute(" & _
.Address & ", ""_"", """"), "" "", """"), ""-"", """")))")
End With
For Each Celda In Rng
p = 0
For ii = 2 To Len(Celda)
If Asc(Mid(Celda, ii, 1)) > 47 And Asc(Mid(Celda, ii, 1)) < 58 Then
p = ii - 1: Exit For
End If
Next ii
If p > 0 Then Celda = Left(Celda, p) & _
Format(Right(Celda, Len(Celda) - p), "_000")
Next Celda
With Application: .ScreenUpdating = True: .Goto Rng(1): End With
Set Rng = Nothing
End Sub
Dos mil alfanuméricos podría llegar a procesarlos en menos de medio segundo.
Comenta como te fue, ¿si?
Saludos, Cacho. ![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)
Última edición por mrocf; 06/11/2008 a las 22:04 |