Las macros de excel no se ejecutan si los datos están en tablas ?

Los colaboradores expertos, Dios los bendiga por compartir su conocimiento.

Tengo un libro de trabajo con datos normalizados en forma de base de datos, y ejecuto unas macros para reportes, hasta hay funciona bien. Se me ocurrió aplicarle a las hojas donde están los datos convertirlas como tablas para que mejorara la presentación y a su vez para que los registros nuevos se aplicaran los formatos y formulas automáticamente, pero una vez realizado esto las macros ya no se ejecutan o eso es lo que observo.

¿La pregunta es que si existen tipos de restricciones o cambia el procedimiento si los datos están en forma de tabla?

He consultado pero no he visto respuesta alguna en la red.

2 Respuestas

Respuesta
1

Depende de la forma en que este programada la macro, en teoría no debería de afectar yo programo de macros con tablas insertadas y tablas normales y de las dos por mucho prefiero programar con tablas insertadas facilita bastante la programación, habría que ver como son llamados los datos por tus macros.

Usé este código de un experto Programar en Excel y me funciono en tablas normales pero cuando le aplique tablas insertadas solo apareció el primer registro.

Es un bucle  que busca unos datos de una hoja y los pega en otra.

Sub Search()
Application.ScreenUpdating = False
Dim filac, filabr, filam As Integer
filac = 2
filabr = 2
filam = 2
    While Sheets("code").Cells(filac, 1) <> Empty
    While Sheets("branch").Cells(filabr, 1) <> Empty
    dato1 = Sheets("code").Cells(filac, 1)
    dato2 = Sheets("branch").Cells(filabr, 1)
       If Sheets("code").Cells(filac, 1) = Sheets("branch").Cells(filabr, 1) Then
      Sheets("main").Cells(filam, 1) = Sheets("branch").Cells(filabr, 1)
      Sheets("main").Cells(filam, 2) = Sheets("branch").Cells(filabr, 2)
      Sheets("main").Cells(filam, 3) = Sheets("branch").Cells(filabr, 3)
      Sheets("main").Cells(filam, 4) = Sheets("branch").Cells(filabr, 4)
      Sheets("main").Cells(filam, 5) = Sheets("branch").Cells(filabr, 5)
      Sheets("main").Cells(filam, 6) = Sheets("branch").Cells(filabr, 6)
      filam = filam + 1
      End If
    filabr = filabr + 1
    Wend
filac = filac + 1
filabr = 2
Wend
Application.ScreenUpdating = True
End Sub

Use varias veces tu código con información convertida en tablas y esto paso, la macro encontró las celdas de la hoja code que coincidían con la hoja branch y las paso a la hoja main, en este caso fueron 3 coincidencias.

estoy haciendo pruebas con un libro en blanco y no me arranca, solo llega al registro 1 pero de hay nada.

algún correo que pueda enviarte el archivo para que me ayudes donde esta el error.  

Postdata no estoy usando tablas de excel solo datos normales

Sub Busca()
Application.ScreenUpdating = False
Dim Nov, Pnal, Nom As Integer
Nov = 5
Pnal = 5
Nom = 10
'On Error Resume Next
While Sheets(2).Cells(Nov, 1) <> Empty
    While Sheets(1).Cells(Pnal, 1) <> Empty
    dato1 = Sheets(2).Cells(Nov, 1).Value
    dato2 = Sheets(3).Cells(Pnal, 1).Value
       If Sheets(2).Cells(Nov, 1) = Sheets(1).Cells(Pnal, 1) Then
        'If dato1 = dato2 Then
      Sheets(3).Cells(Nom, 2) = Sheets(1).Cells(Pnal, 1)
      Sheets(3).Cells(Nom, 3) = Sheets(1).Cells(Pnal, 8)
      Sheets(3).Cells(Nom, 4) = Sheets(1).Cells(Pnal, 9)
      Sheets(3).Cells(Nom, 5) = Sheets(1).Cells(Pnal, 10)
      Sheets(3).Cells(Nom, 6) = Sheets(1).Cells(Pnal, 11)
      Sheets(3).Cells(Nom, 7) = Sheets(1).Cells(Pnal, 12)
      Sheets(3).Cells(Nom, 8) = Sheets(1).Cells(Pnal, 13)
      Sheets(3).Cells(Nom, 9) = Sheets(1).Cells(Pnal, 7)
      Sheets(3).Cells(Nom, 10) = Sheets(1).Cells(Pnal, 24)
      Sheets(3).Cells(Nom, 11) = Sheets(1).Cells(Pnal, 25)
      Sheets(3).Cells(Nom, 12) = Sheets(1).Cells(Pnal, 26)
      Sheets(3).Cells(Nom, 13) = Sheets(1).Cells(Pnal, 27)
      Sheets(3).Cells(Nom, 14) = Sheets(1).Cells(Pnal, 15)
      Sheets(3).Cells(Nom, 33) = Sheets(1).Cells(Pnal, 23)
      Sheets(3).Cells(Nom, 15) = Sheets(2).Cells(Nov, 3)
      Sheets(3).Cells(Nom, 16) = Sheets(2).Cells(Nov, 4)
      Sheets(3).Cells(Nom, 20) = Sheets(2).Cells(Nov, 5)
      Sheets(3).Cells(Nom, 26) = Sheets(2).Cells(Nov, 6)
      Sheets(3).Cells(Nom, 27) = Sheets(2).Cells(Nov, 7)
      Sheets(3).Cells(Nom, 32) = Sheets(2).Cells(Nov, 8)
      Nom = Nom + 1
      End If
    Pnal = Pnal + 1
    Wend
Nov = Nov + 1
Pnal = 2
Wend
Application.ScreenUpdating = True
End Sub

el código lo adapte para tres hojas (1) (2) y (3)  y busque de la dos en la 1 y pegue en la 3 y la 2 pegue en la 3 también

Prueba con este código es un pocoi más rápido que el que tratas de usar funciona para tablas normales, para tablas insertadas cambia un poco la programación.

Sub BUscar_info()
Set h1 = Worksheets("code")
Set h2 = Worksheets("branch")
Set h3 = Worksheets("main")
Set code = h1.Range("a5").CurrentRegion
Set branch = h2.Range("a5").CurrentRegion
Set main = h3.Range("a10").CurrentRegion
With branch
    r = .Rows.Count
    x = 1
    For i = 1 To r
        dato = .Cells(i, 1)
            For j = 1 To code.Rows.Count
                dato2 = code.Cells(j, 1)
                coinciden = dato = dato2
                If coinciden Then
                cuenta = WorksheetFunction.CountA(x) > 1
                If cuenta Then GoTo sig
                    With main
                        .Cells(x, 2) = code.Cells(j, 1)
                        .Cells(x, 3) = code.Cells(j, 8)
                        .Cells(x, 4) = code.Cells(j, 9)
                        .Cells(x, 5) = code.Cells(j, 10)
                        .Cells(x, 6) = code.Cells(j, 11)
                        .Cells(x, 7) = code.Cells(j, 12)
                        .Cells(x, 8) = code.Cells(j, 13)
                        .Cells(x, 9) = code.Cells(j, 7)
                        .Cells(x, 10) = code.Cells(j, 24)
                        .Cells(x, 11) = code.Cells(j, 25)
                        .Cells(x, 12) = code.Cells(j, 26)
                        .Cells(x, 13) = code.Cells(j, 27)
                        .Cells(x, 14) = code.Cells(j, 15)
                        .Cells(x, 33) = code.Cells(j, 23)
                        .Cells(x, 15) = branch.Cells(j, 3)
                        .Cells(x, 16) = branch.Cells(j, 4)
                        .Cells(x, 20) = branch.Cells(j, 5)
                        .Cells(x, 26) = branch.Cells(j, 6)
                        .Cells(x, 27) = branch.Cells(j, 7)
                        .Cells(x, 32) = branch.Cells(j, 8)
                        x = x + 1
                    End With
                End If
sig:
            Next j
    Next i
End With
Set h1 = Nothing: Set h2 = Nothing: Set h3 = Nothing
Set code = Nothing: Set branch = Nothing: Set main = Nothing
End Sub
Respuesta
1

Puede que hayas anulado la ejecución de las macro fíjate en archivo opciones centro de confianza habilitar macros Excel.

Acá puedes encontrar algo más que te ayude

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas