Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Corrección de código o control de error

publicado

Hola tengo un código en excel para transferir datos a una tabla en access, la configuración de la tabla es: Campo llave es numérico; y los otro dos campos son tipo texto. En excel la primer columna es una fórmula de conteo correlativo y el resultado es un número por fila: =SI.ERROR(SI(B2="","",FILA()-1)+PARÁMETROS!$B$5,"")

antes de agregar esa columna en mención, la transferencia funcionaba muy bien, de no poderse corregir el código, quisiera optar por controlar dicho error, y quisiera saber si es posible saltarlo y que continúe la ejecusión, gracias por su ayuda de antemano. Saludos!!!

Sub ExcelaAccess_ADO()

Dim Conn As ADODB.Connection, RecSet As ADODB.Recordset
Dim fila As Long, primerFila As Integer, ultimaFila As Long, iX As Long
Dim dataSource As String, Tabla As String
Dim wsName As String

'definimos los parametros que seran usados por el codigo
dataSource = Sheets("PARÁMETROS").[B1]
Tabla = Sheets("PARÁMETROS").[B2]
wsName = Sheets("PARÁMETROS").[B3]
primerFila = Sheets("PARÁMETROS").[B4]

' establecemos la conexion a la base de datos
Set Conn = New ADODB.Connection
'Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;
Conn.Open "Provider = Microsoft.ACE.OLEDB.12.0;Data Source= " & _
dataSource & ";"

' definimos un recordset
Set RecSet = New ADODB.Recordset
RecSet.Open Tabla, Conn, adOpenKeyset, adLockOptimistic, adCmdTable

ultimaFila = WorksheetFunction.CountA(Sheets(wsName).Range("A:A"))

For iX = primerFila To ultimaFila 'mientras que la celda la columna A
'tenga un valor transferimos la fila
With RecSet
.AddNew
.Fields("CodTema") = Sheets(wsName).Cells(iX, 1).Value
.Fields("Temarios") = Sheets(wsName).Cells(iX, 2).Value
.Fields("CodLib") = Sheets(wsName).Cells(iX, 3).Value
.Update
End With
Next iX

RecSet.Close
Set RecSet = Nothing
Conn.Close
Set Conn = Nothing
End Sub[/CODE]

Featured Replies

publicado

Sin el archivo y la base de datos, es imposible ayudarte.

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.