Pasar datos a una plantilla automáticamente_incluir operaciones con fórmulas
Hace un tiempo hice una pregunta para pasar los datos automáticamente de un archivo a otro con un formato determinado.
El código era como el que indico más abajo. Me gustaría saber cómo hacer para que automáticamente me hiciera cálculos, por ejemplo:
Que calculara el tax percentage, en vez de coger sin más el dato.
La macro que he creado es:
Sub Tax_percentage_2()
'
' Tax_percentage_2 Macro
'
'
 Sheets("datos").Select
 Range("AI46").Select
 ActiveCell.FormulaR1C1 = "=+IFERROR((RC[1]/RC[-9]),0)"
 Selection.AutoFill Destination:=Range("AI46:AI40000")
 Range("AI46:AI40000").Select
 ActiveWindow.SmallScroll Down:=27
End Sub
Y también otras similares y me gustaría saber como incluir estas operaciones en la macro principal.
Sub InvoiceNumber()
'Por.Dante Amor
    Set h1 = Sheets("datos")
    Set h2 = Sheets("ej1")
    Set h3 = Sheets("plantilla")
    h2.Cells.Clear
    '
    j = 1
    i = 2
    n = 0
    '
    ant = h1.Cells(2, "F")
    encabezado h1, h2, h3, i, j
    For i = 2 To h1.Range("F" & Rows.Count).End(xlUp).Row
        If ant <> h1.Cells(i, "f") Then
            n = 0
            encabezado h1, h2, h3, i, j
        End If
        ant = h1.Cells(i, "F")
        If h1.Cells(i, "P") = "Duty Charges" Then
            duty h1, h2, h3, i, j, n
        Else
            n = n + 1
            productos h1, h2, h3, i, j, n
        End If
    Next
    h2.Select
    MsgBox "Proceso terminado", vbInformation, "PLANTILLA"
End Sub
Sub encabezado(h1, h2, h3, i, j)
'Por.Dante Amor
    h3.Rows(1 & ":" & 3).Copy h2.Rows(j)
    '
    h2.Cells(j, "B") = h1.Cells(i, "F")  'invoice num
    h2.Cells(j, "C") = h1.Cells(i, "J")  'invoice date
    h2.Cells(j, "D") = h1.Cells(i, "G")  'CURRENCY
    h2.Cells(j, "E") = h1.Cells(i, "AB") 'PO
    h2.Cells(j, "F") = h1.Cells(i, "O")  'PAYMENT_TERM
    j = j + 1
    h2.Cells(j, "B") = h1.Cells(i, "A")  'BILL_TO_CUSTOMER_NAME
    h2.Cells(j, "C") = h1.Cells(i, "Y")  'VAT NUMNER PURCHASING COMPANY
    j = j + 1
    h2.Cells(j, "B") = h1.Cells(i, "Z")  'SELLER
    h2.Cells(j, "C") = h1.Cells(i, "AA") 'SELLER VAT
    j = j + 1
End Sub
Sub productos(h1, h2, h3, i, j, n)
'Por.Dante Amor
    h3.Rows(4 & ":" & 6).Copy h2.Rows(j)
    '
    h2.Cells(j, "B") = n                 'consecutivo
    h2.Cells(j, "C") = h1.Cells(i, "P")  'DESCRIPTION
    j = j + 1
    h2.Cells(j, "C") = h1.Cells(i, "K")  'QUANTITY_INVOICED
    h2.Cells(j, "D") = h1.Cells(i, "M")  'EXTENDED_AMOUNT
    h2.Cells(j, "K") = h1.Cells(i, "V")  'TAX_TOTAL
    j = j + 2
End Sub
Sub duty(h1, h2, h3, i, j, n)
'Por.Dante Amor
    h3.Rows(19 & ":" & 21).Copy h2.Rows(j)
    '
    h2.Cells(j, "B") = n                 'consecutivo
    'h2.Cells(j, "C") = h1.Cells(i, "P")  'DESCRIPTION
    j = j + 1
    h2.Cells(j, "C") = h1.Cells(i, "K")  'QUANTITY_INVOICED
    h2.Cells(j, "D") = h1.Cells(i, "M")  'EXTENDED_AMOUNT
    h2.Cells(j, "K") = h1.Cells(i, "V")  'TAX_PERCENTAGE
    j = j + 2
End Sub
        1 respuesta
                    Respuesta de Dante Amor                
                
        
        
            
                1
              
        
        
        
            
            
        
    
                