Mejorar macro de búsqueda e inserción de filas

Estoy aqui de nuevo, porque he avanzado una macro con la ayuda de ustedes, pero ya no doy mas. La macro busca el texto de combobox en la hoja 3, cuando lo encuentra, se pone una fila debajo y deberia de insertar 5 filas hacia abajo, pero no lo hace. ¿Y cómo hacer para que reconozca la primera fila que a insertado? Ya que necesitare que ingrese datos del combobox2 en esa primera fila. Aqui lo que pude hacer:

Private Sub CommandButton1_Click()
On Error Resume Next
Set busco = Sheets("Hoja3").Range("A:A").Find(Trim(ComboBox1.value), LookIn:=xlValues, lookat:=xlWhole)
If Not busco Is Nothing Then
        ActiveCell = busco.Offset(1, 0)
        numFilas = 5
        If numFilas > 0 Then
        Rows(ActiveCell.Row & ":" & ActiveCell.Row + numFilas - 1).Insert
        End If
End If
End Sub

1 Respuesta

Respuesta
1

He logrado armar la macro, pero tiene un problema, que no inserta las filas en forma descendente, no se que hice mal, ayuda por favor:

Private Sub CommandButton1_Click()
Dim d
Application.ScreenUpdating = False
On Error Resume Next
   Sheets("Hoja3").Activate
   Columns(1).Find(ComboBox1.Text).Select
    ActiveCell.Offset(2, 0).Select
    numFilas = 5
        If numFilas > 0 Then
        Rows(ActiveCell.Row & ":" & ActiveCell.Row + numFilas - 1).Insert Shift:=xlDown
                ActiveCell.Offset(0, 0) = CDbl(TextBox3)
                ActiveCell.Offset(0, 1) = TextBox4
                ActiveCell.Offset(0, 2) = TextBox2
                ActiveCell.Offset(0, 3) = ComboBox2.Text
                ActiveCell.Offset(0, 4) = TextBox5
                ActiveCell.Offset(0, 5) = CDbl(TextBox1)
                ActiveCell.Offset(0, 6) = TextBox6
                ActiveCell.Offset(0, 7) = TextBox7
                ActiveCell.Offset(0, 8) = CDbl(TextBox8)
                ActiveCell.Offset(0, 9) = TextBox9
                ActiveCell.Offset(0, 10) = TextBox10
                ActiveCell.Offset(0, 11) = TextBox11
                Sheets("Hoja2").ShowAllData
                Sheets("Hoja3").ShowAllData
        End If
Hoja1.Activate
Unload Me
MsgBox "Datos ingresados correctamente..."
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas