Tengo un problema con el error 1004 en excel vba 2016
Tengo el siguiente problema en un archivo de excel con macros
Se ha producido el error 1004 en tiempo de ejecución:
Error en el método ´range´de objeto_global
A continuación les dejo el modulo y agradezco su ayuda
Private Sub UserForm_Activate()
Me.TXTFECHA = Date
End Sub
Private Sub UserForm_Initialize()
Me.nremision = Hoja5.Range("O1")
Me.dremitente = Hoja1.usuarionombre
With ListBox1
.ColumnCount = 5
.ColumnWidths = "45 pt;300 pt;100 pt;45 pt;25 pt" ' Unidades de medida, 72 pt(puntos)=1 Pulgada
End With
Dim Rango, celda As Range
Set Rango = Range("tipo")
For Each celda In Rango
TIPO_D.AddItem celda.Value
Next celda
Dim Fila As Integer, Final As Integer, REGISTRO As Integer
Fila = 1
Do While hoja9.Cells(Fila, 1) <> ""
Fila = Fila + 1
Loop
Final = Fila - 1
With hoja9
For Fila = 2 To Final
REGISTRO = WorksheetFunction.CountIf(.Range(.Cells(1, 1), .Cells(Fila, 1)), .Cells(Fila, 1))
If REGISTRO = 1 Then
TXTEMPRESA.AddItem .Cells(Fila, 1)
End If
Next Fila
End With
End Sub
Private Sub V_PREVIA_Click()
Application.ScreenUpdating = False
Dim Fila As Long
Dim Final As Long
Dim xtxtcaja As String
Dim xnremision As Long
Dim xtxtdocumento As String
Dim xtxtcant As String
Dim xtipotxt As String
Dim XC_INGRESO As String
Titulo = "SOLUCIONES INTEGRALES DE ARCHIVO E.U."
If Me.TXTEMPRESA = Empty Then
MsgBox "Ingrese Datos de Destinatario!", , Titulo
TXTEMPRESA.SetFocus
Exit Sub
End If
For i = 0 To Me.ListBox1.ListCount - 1
XC_INGRESO = Me.ListBox1.List(i, 0)
xtxtdocumento = Me.ListBox1.List(i, 1)
xtxtcaja = Me.ListBox1.List(i, 2)
xtipotxt = Me.ListBox1.List(i, 3)
xtxtcant = Me.ListBox1.List(i, 4)
Final = GetNuevoRemi(Hoja5)
Hoja5.Cells(Final, 1) = xtxtdocumento
Hoja5.Cells(Final, 9) = xtxtcaja
Hoja5.Cells(Final, 5) = xtipotxt
Hoja5.Cells(Final, 7) = Val(xtxtcant)
Hoja5.Cells(Final, 11) = XC_INGRESO
Hoja5.Range("d5") = Me.TXTSOLICITANTE
Hoja5.Range("b5") = Me.TXTEMPRESA
Hoja5.Range("k1") = Me.nremision
Hoja5.Range("b24") = Me.dremitente
Hoja5.Range("I5") = Me.TXTFECHA
Final = Final + 1
Next
ActiveWorkbook.Worksheets("Frtremision").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Frtremision").Sort.SortFields.Add Key:=Range( _
"E8:E25"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Frtremision").Sort
.SetRange Range("A8:G25")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.GoTo Reference:="CANTIDAD"
Selection.Copy
Range("J8").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
vistaprevia.Show
End Sub