ERROR 1004' al cambiar el valor en una celda
Estoy haciendo un código que al indicar un valor en un combobox, lo busque en una hoja específica y al encontrarlo, me copie ciertos valores en celdas de otra hoja, al momento de indicar que me copie los valores de la "hoja1=cotizaciones", en la "hoja2=formulario", me arroja un error del tipo 1004, he intentado colocar el código de diversas maneras pero aún no logro encontrar el error.
Private Sub ComboBox2_Click()
Set h2 = Sheets("COTIZACIONES")
Set h3 = Sheets("FORMULARIO")
Dim fila As Long
For i = 4 To h2.Range("C" & Rows.Count).End(xlUp).Row
If h2.Cells(i, "C") = ComboBox2.Value Then
fila = i
End If
Next
h3.Cells(7, 4).Value = h2.Cells(fila, 4).Value 'Nombre empresa
h3.Cells(8, "D").Value = h2.Cells(fila, "G").Value 'FECHA
h3.Cells(10, "D").Value = h2.Cells(fila, "H").Value 'AREA
h3.Cells(11, "D").Value = h2.Cells(fila, "A").Value 'COD COTIZACION
h3.Cells(15, "C").Value = h2.Cells(fila, "K").Value 'OBJETIVOS
h3.Cells(4, "Q").Value = h2.Cells(fila, "U").Value 'PLAZOS
h3.Cells(8, "Q").Value = h2.Cells(fila, "L").Value 'VALIDEZ
h3.Cells(13, "M").Value = h2.Cells(fila, "N").Value 'EXCEPCIONES
h3.Cells(19, "M").Value = h2.Cells(fila, "M").Value 'OBSERVACIONES
'Carta Gantt
h3.Cells(25, "BB").Value = h2.Cells(fila, "Q").Value 'inicio
h3.Cells(27, "BB").Value = h2.Cells(fila, "R").Value 'revision A
h3.Cells(29, "BB").Value = h2.Cells(fila, "S").Value 'revision O
h3.Cells(31, "BB").Value = h2.Cells(fila, "T").Value 'finalizacion
'llenar detalle pago
If h2.Cells(fila, "P") = 1 Then
h3.Range("M37:N39").Value = Worksheets("HOJA MAESTRA").Range("U8:V10").Value
borde1
End If
If h2.Cells(fila, "P") = 2 Then
h3.Range("M37:N40").Value = Worksheets("HOJA MAESTRA").Range("W8:X11").Value
borde2
End If
End SubAl depurar el código, el error comienza a partir de esta línea:
h3.Cells(7, 4).Value = h2.Cells(fila, 4).Value 'Nombre empresa
La variable fila, al colocarla como Integer o Long me arroja el error igual.
1 respuesta
Respuesta de Dante Amor
1