Se ha producido el error -2147417848 (80010108) en tiempo de ejecución

MrEnfrijoladas 0 Puntos de reputación
2025-08-08T21:35:51.9066667+00:00

Hice una base de datos con un formulario, todo funciono de maravilla, por lo tanto, copie esta base de datos dos veces ya que ocuparíamos la base para chicos de preparatoria y universidad, lo único que cambie fue un rango llamado "clavess" este rango tenía claves del 1 al 99 así: ES242501, y las cambie a SL252601 (esto porque hay un combobox donde hay que seleccionar estas claves), creo que fue lo único que hace que me lance ese error y se me cierre Excel en automático (Se ha producido el error '-2147417848 (80010108) en tiempo de ejecución: Error en el método 'Insert' de objeto 'Range') este error se arroja al momento que presiono el botón de agregar, es decir, dar de alta los datos, no me paso hasta que cambie el cómo era la clave, a continuación, les dejo el código del botón agregar, de antemano muchísimas gracias

Private Sub BT_AGREGAR2_Click()
 
Sheets("BDPAGOS").Range("C3").EntireRow.Insert


Range("B3").Value = Me.ComboCLAVE.Value
Range("C3").Value = Me.TextNUMPAGO.Value
Range("D3").Value = Me.TextFECHA.Value
Range("E3").Value = Me.TextMONTO.Value
Range("F3").Value = Me.TextNOMBRE.Value

Me.LISTA.RowSource = "TBLPAGOS"
Me.LISTA.ColumnCount = 5
 
Me.ComboCLAVE.Value = Empty
Me.TextNUMPAGO.Value = Empty
Me.TextFECHA.Value = Empty
Me.TextMONTO.Value = Empty
Me.TextNOMBRE.Value = Empty

clave = Sheets("BDPAGOS").Range("B1")

Me.ComboCLAVE = clave

Me.TextNUMPAGO.SetFocus

UserForm1.Height = 263.25

Me.BT_ELIMINAR.Enabled = True
Me.BT_ELIMINAR2.Enabled = True


End Sub

Microsoft 365 y Office | Excel | Otros | Windows
0 comentarios No hay comentarios
{count} votos

1 respuesta

Ordenar por: Muy útil
  1. Peter ED 1,780 Puntos de reputación Personal externo de Microsoft Moderador
    2025-08-09T00:59:37.58+00:00

    Hello,

    Thanks for reaching out to Microsoft Q&A forum support.

    I understand you are experiencing a runtime error -2147417848 (80010108) when attempting to insert a row in an Excel sheet using VBA.

    This error often arises when Excel is in an inconsistent state, especially after duplicating workbooks or modifying named ranges. In your case, changing the "keys" range from ES242501 to SL252601 may have introduced a reference or context issue that affects the Insert method.

    To resolve this issue, please follow the steps below:

    1. Ensure Excel is not in Edit Mode or Active Cell State Before running the macro, make sure no cell is actively being edited or selected in a way that could interfere with VBA execution.

    This helps prevent Excel from locking the sheet context during macro execution.

    2. Explicitly Activate the Target Sheet Before Inserting

    For instance, modify your code to activate the sheet before performing the insert operation:

    Sheets("BDPAGOS").Activate

    Sheets("BDPAGOS").Range("C3").EntireRow.Insert

    Activating the sheet ensures that the VBA context is correctly aligned with the target worksheet.

    3. Test in a New Workbook

    Copy your VBA code and form into a fresh workbook and test the macro.

    This isolates the issue and confirms whether the error is workbook specific.

    Best wishes,

    Peter | Microsoft Q&A Support Moderator

    0 comentarios No hay comentarios

Su respuesta

Las respuestas pueden ser marcadas como "Aceptadas" por el autor de la pregunta y "Recomendadas" por los moderadores, lo que ayuda a los usuarios a saber que la respuesta ha resuelto el problema del autor.