Macro entrada datos no funciona
Hola tengo una macro para copiar los datos de la hoja1 a la primera fila de la hoja Llireg. No ese si he cambiado algo sin darme cuenta porque al principio me funcionaba pero ahora en lugar de ponerme los datos en la hoja llireg los coloca en la hoja1. Este es el código:
Private Sub CommandButton1_Click()
Dim iFila As Long
Dim ws As Worksheet
Set ws = Worksheets(2)
Application.ScreenUpdating = False
Sheets("Hoja2").Select
uf = Range("B" & Cells.Rows.Count).End(xlUp).Row
For fil = 1 To uf
If Range("B" & fil) = "" Then
Rows(fil & ":" & fil).Delete Shift:=xlUp
fil = fil - 1
uf = Range("B" & Cells.Rows.Count).End(xlUp).Row
If uf <= fil Then Exit Sub
End If
Next fil
' Encuenta la siguiente fila vacía
iFila = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(iFila, 1).Value = Sheets("LLIREG").[C1]
ws.Cells(iFila, 2).Value = Sheets("LLIREG").[c30]
LR = [A1].End(xlDown).Row
Range("a1:m" & LR).Sort Key1:=[A1], Order1:=xlAscending, _
Key2:=[b1], Order2:=xlAscending, _
Header:=xlYes
Sheets("LLIREG").Select
Application.ScreenUpdating = True
End
End Sub
Gracias
Private Sub CommandButton1_Click()
Dim iFila As Long
Dim ws As Worksheet
Set ws = Worksheets(2)
Application.ScreenUpdating = False
Sheets("Hoja2").Select
uf = Range("B" & Cells.Rows.Count).End(xlUp).Row
For fil = 1 To uf
If Range("B" & fil) = "" Then
Rows(fil & ":" & fil).Delete Shift:=xlUp
fil = fil - 1
uf = Range("B" & Cells.Rows.Count).End(xlUp).Row
If uf <= fil Then Exit Sub
End If
Next fil
' Encuenta la siguiente fila vacía
iFila = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(iFila, 1).Value = Sheets("LLIREG").[C1]
ws.Cells(iFila, 2).Value = Sheets("LLIREG").[c30]
LR = [A1].End(xlDown).Row
Range("a1:m" & LR).Sort Key1:=[A1], Order1:=xlAscending, _
Key2:=[b1], Order2:=xlAscending, _
Header:=xlYes
Sheets("LLIREG").Select
Application.ScreenUpdating = True
End
End Sub
Gracias