Necesito ordenar una tabla de excel automáticamente a medida que voy introduciendo los datos en un formulario

Necesito ordenar una tabla de excel automáticamente a medida que voy introduciendo los datos en un formulario, he copiado el código del señor Dante pero parece que tengo un error y no me funciona:

A continuación el código y la tabla: la misma comienza en la columna 3 y la ultima columna es la 7 Comentar.

El código es el siguientes:

Public fila As String
Private Sub Worksheet_Activate()
On Error Resume Next
fila = 1
Sheets("Tabelle5").Cells(fila, 1).Select
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
'On Error Resume Next

'solo se ejecuta si se modifica la columna D
If Target.Column = 7 Then
fila = ActiveCell.Row

Dim uf, ucw, r1, r2 As String
Dim x, ucn As Integer

Sheets("Tabelle5").Select
'determines last row with data

uf = Sheets("Tabelle5").Range("A" & Rows.Count).End(xlUp).Row
uc = Sheets("Tabelle5").Cells("1," & Columns.Count).End(xlToRight).Address(False, False)
ucw = Mid(uc, 1, 1)
ucn = Sheets("Tabelle5").Cells("1," & Columns.Count).End(xlToRight).Column

x = 1

'will help determine ranges to sort data
k = Sheets("Tabelle5").Cells(2, 1).Address(False, False)
k1 = Mid(k, 1, 1)
r1 = k & ":" & k1 & uf
r2 = "A1:" & ucw & uf
'sorts the data
ActiveWorkbook.Worksheets("Tabelle5").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Tabelle5").Sort.SortFields.Add Key:=Range(r1) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Tabelle5").Sort
.SetRange Range(r2)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Cells.Select
Selection.Copy Destination:=Sheets("Hoja2").Range("A1")
Sheets("hoja2").Select
Sheets("Tabelle5").Select
End If

Application.ScreenUpdating = False
End Sub

Añade tu respuesta

Haz clic para o