¿Qué es el programa vba?
Utilice código para realizar la automatización. La interfaz es solo un botón. Puede completar el cálculo de la tabla salarial o generar recibos salariales automáticamente con un solo clic.
Esta es la interfaz de operación.
Private Sub CommandButton3_Click() 'Comprobar relleno
Atenuar skUArr(1 a 1000, 1 a 3)
Atenuar skUGs como entero
Dim hH como entero
Dim zlHH como entero
Cells.Find(What:="Peso de la caja", After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, MatchByte:=False, SearchFormat:=False).Activate
zlHH = ActiveCell.Row 'Número de fila de peso
skmGs = 0
hH = 5
Hacer mientras Trim(Cells(hH, 1).Text ) <> ""
? skUGs = skUGs + 1
skUArr(skUGs, 1) = Recortar(Celdas(hH, 1).Texto)
? skUArr(skUGs, 2) = Recortar(Celdas(hH, 4).Texto)
? skUArr(skUGs, 3) = Celdas(hH, 10).Valor
?
? hH = hH + 1
Bucle
Atenuar fName como cadena
Atenuar SBook como libro de trabajo
Llamar a SelectFile(fName)
Establecer SBook = Workbooks.Open(fName)
Dim M_sku como cadena, M_fnSku como cadena, M_qty como entero
Con SBook .Sheets(1)
? Para I = 1 Para skUGs
?M_sku = Trim(.Cells(5 + I - 1, 1).Text)
?M_fnSku = Trim(.Cells(5 + I - 1, 4).Text)
?M_qty = .Cells(5 + I - 1, 9).Value
?If skUArr(I, 1) <> M_sku Then
MsgBox ("¡El SKU del registro "th" & I & "es inconsistente! ")
Salir de Sub
?End If
?If skUArr(I, 2) <> M_fnSku Then
MsgBox (" El FNSKU del registro "& I & " es inconsistente ")
Salir Sub
?End If
?If skUA
rr(I, 3) <> M_qty Then
MsgBox ("¡La CANTIDAD del registro "ésimo" & I & "es inconsistente!")
Salir de Sub
?End If
?
? Siguiente I
Terminar con
Dim qtyArr() como entero
Dim boxGs como entero
Dim boxArr()
Con ThisWorkbook.Sheets(1)
? boxGs = .Cells(4, 200). End(xlToLeft ).Column
? ReDim qtyArr(1 a skUGs, 1 a boxGs)
? ReDim boxArr(1 a 4, 1 a boxGs)
? ' Número de lecturas
? Para I = 1 Para skUGs
?Para J = 1 Para boxGs
qtyArr(I, J) = .Cells (5 + I - 1, 12 + J - 1).Valor
?Siguiente J
? Siguiente I
?'Leer cuadro
? Para I = 1 a 4
?Para J = 1 a boxGs
boxArr(I, J) = .Cells(zlHH + I - 1, 12 + J - 1 ).Valor
?Siguiente J
? Siguiente I
Terminar con
'Rellenar
Con SBook .Sheets(1)
? '.Cells(5, 12).Resize(skUGs, boxGs) = qtyArr
'.Cells(zlHH, 12).Resize (4, boxGs) = boxArr
? Para I = 1 a skUGs
?Para J = 1 a boxGs
Si qtyArr(I, J) > 0 Entonces
.Cells(5 + I - 1, 12 + J - 1) = qtyArr(I, J)
Fin
?Siguiente J p>
? Siguiente I
? Para I = 1 a 4
?Para J = 1 a boxGs
.Cells(zlHH + I - 1, 12 + J - 1) = boxArr(I, J)
?Siguiente J
? Siguiente I
Terminar con
SBook.Save
MsgBox ("¡Comprobar resultado correcto, llenado completado! ")
End Sub
Este es el código de uno de los botones como referencia.