Tengo la siguiente macro para el registro de datos en la factura
Sub GuardarFactura()
Dim NombreHoja As String
Dim HojaDestino As Range
Dim NuevaFila As Integer
Dim FilasFactura As Integer
Dim i As Integer
Dim j As Integer
Dim NumFactura As Integer
NombreHoja = "DetalleFacturas"
> ***FilasFactura = Application.WorksheetFunction.CountA(Range("Factura[CODIGO]"))***
NumFactura = ThisWorkbook.Sheets("Factura").Range("F5").Value
With ThisWorkbook.Sheets(NombreHoja)
For i = 1 To FilasFactura
Set HojaDestino = ThisWorkbook.Sheets(NombreHoja).Range("B6").CurrentRegion
NuevaFila = HojaDestino.Rows.Count + 1
.Cells(NuevaFila, 1).Value = Date
.Cells(NuevaFila, 2).Value = NumFactura
.Cells(NuevaFila, 3).Value = Range("F7").Value
For j = 1 To 5
.Cells(NuevaFila, j + 3).Value = ThisWorkbook.Sheets("Factura").Cells(9 + 1, 1 + j)
Next j
Next i
End With
MsgBox ("Registro Exitoso")
End Sub
Application.WorksheetFunction.CountA(ThisWorkbook.Sheets("Factura").Range("Factura[CODIGO]"))