Consejo: Otros idiomas son traducidos por Google. Puedes visitar el English versión de este enlace.
Iniciar sesión
x
or
x
x
Suscríbete
x

or

¿Cómo incrementar automáticamente el valor de la celda después de cada impresión?

Supongamos que tengo una página de la hoja de trabajo necesaria para imprimir las copias de 100, la celda A1 es el número de verificación Compañía-001, ahora, me gustaría que el número aumente por 1 después de cada impresión. Eso significa que cuando imprima la segunda copia, el número se incrementará a Company-002 automáticamente, la tercera copia, el número será Company-003 ... cien copias, el número será Company-100. ¿Hay algún truco para resolver este problema en Excel de forma rápida y posiblemente?

Aumente automáticamente el valor de la celda después de cada impresión con código VBA


Imprimir páginas impares, pares, actuales o especificadas de una hoja de trabajo

Kutools for Excel's Imprimir páginas especificadas la utilidad puede ayudarlo a imprimir rápidamente páginas impares, uniformes, actuales o especificadas según lo necesite.

incremento de doc al imprimir 2

Kutools for Excel: con más de 200 útiles complementos de Excel, de prueba sin límite en días 60. Descargar y prueba gratis ahora!


flecha azul burbuja derecha Aumente automáticamente el valor de la celda después de cada impresión con código VBA


Normalmente, no hay una manera directa de resolver esta tarea en Excel, pero aquí crearé un código VBA para manejarlo.

1. Mantenga presionado el ALT + F11 teclas para abrir el Microsoft Visual Basic para aplicaciones ventana.

2. Hacer clic recuadro > Móduloy pegue el siguiente código en Módulo Ventana.

Código de VBA: Aumento automático del valor de la celda después de cada impresión:

Sub IncrementPrint()
'updateby Extendoffice 20160530
    Dim xCount As Variant
    Dim xScreen As Boolean
    Dim I As Long
    On Error Resume Next
LInput:
    xCount = Application.InputBox("Please enter the number of copies you want to print:", "Kutools for Excel")
    If TypeName(xCount) = "Boolean" Then Exit Sub
    If (xCount = "") Or (Not IsNumeric(xCount)) Or (xCount < 1) Then
        MsgBox "error entered, please enter again", vbInformation, "Kutools for Excel"
        GoTo LInput
    Else
        xScreen = Application.ScreenUpdating
        Application.ScreenUpdating = False
        For I = 1 To xCount
            ActiveSheet.Range("A1").Value = " Company-00" & I
            ActiveSheet.PrintOut
        Next
        ActiveSheet.Range("A1").ClearContents
        Application.ScreenUpdating = xScreen
    End If
End Sub

3. Entonces presione F5 tecla para ejecutar este código, y se abre un cuadro de aviso para recordarle que ingrese el número de copias que desea imprimir la hoja de trabajo actual, vea la captura de pantalla:

incremento de doc al imprimir 1

4. Hacer clic OK y su hoja de trabajo actual está imprimiendo ahora, y al mismo tiempo, las hojas impresas están numeradas Company-001, Company-002, Company-003 ... en la celda A1 que necesita.

Nota: En el código anterior, la celda A1 se insertarán los números de secuencia que ordenó, y el valor de celda original en A1 se borrará Y "Company-00"Es el número de secuencia, puede cambiarlos a su necesidad.


Kutools for Excel: la mejor herramienta de productividad de Office aumenta su productividad en un 80%

  • Super Formula Bar (edite fácilmente varias líneas de texto y fórmula); Diseño de lectura (lee y edita fácilmente un gran número de celdas); Pegar en rango filtrado...
  • Combinar celdas / filas / columnas y mantener datos; Contenido de celdas divididas; Combinar filas duplicadas y suma / promedio... Prevenir células duplicadas; Comparar rangos...
  • Seleccione Duplicado o Único Filas; Seleccionar filas en blanco (todas las celdas están vacías); Super Find y Fuzzy Find en muchos libros de trabajo; Selección aleatoria ...
  • Copia exacta Celdas múltiples sin cambiar la referencia de fórmula; Crear referencias automáticamente a múltiples hojas; Insertar viñetas, Casillas de verificación y más ...
  • Fórmulas favoritas e insertadas rápidamente, Gamas, cuadros y cuadros; Cifrar celdas con contraseña Crear una lista de correo y enviar correos electrónicos ...
  • Extracto del texto, Agregar texto, Eliminar por posición, Eliminar espacio; Crear e imprimir subtotales de paginación; Convertir entre contenido de celdas y comentarios...
  • Súper filtro (guardar y aplicar esquemas de filtro a otras hojas); Clasificación avanzada por mes / semana / día, frecuencia y más; Filtro especial por negrita, cursiva ...
  • Combinar libros de trabajo y hojas de trabajo; Combinar tablas basadas en columnas clave; Dividir datos en varias hojas; Conversión por lotes xls, xlsx y PDF...
  • Funciona con Office 2007-2019 y 365, y es compatible con todos los idiomas. Es fácil de implementar en su empresa. Funciones completas de prueba gratuita de 60-day.
pestaña kte 201905

Office Tab lleva la interfaz con pestañas a Office y hace que su trabajo sea mucho más fácil

  • Habilitar la edición y lectura con pestañas en Word, Excel, PowerPoint, Editor, Acceso, Visio y Proyecto.
  • Abra y cree varios documentos en nuevas pestañas de la misma ventana, en lugar de en nuevas ventanas.
  • ¡Aumenta tu productividad en un 50% y reduce cientos de clics de ratón por ti todos los días!
fondo officetab
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    TBOne · 1 months ago
    I was wondering how to make a small change so that it prints 1 of 10, 2 of 10, 3 of 10, etc.
    Otherwise this works great. Thanks.
  • To post as a guest, your comment is unpublished.
    unknown · 4 months ago
    hey i want to change number of K11 cell number after print to 1-2-3-4-5-6 etc pls can u help ? and also tell me how to call that function pls help
  • To post as a guest, your comment is unpublished.
    Ib Alsa · 5 months ago
    Is there a way to select what values I want to print? for example I printed sequence 1 to 30 but need to reprint sequence 15 to 19 again.
  • To post as a guest, your comment is unpublished.
    Bill Turek · 5 months ago
    Works good for printing incremental #'s. How do I print every 5th,10, when needed?
  • To post as a guest, your comment is unpublished.
    Arash · 7 months ago
    Thanks a million
  • To post as a guest, your comment is unpublished.
    jennifer · 8 months ago
    My cell is I3 and the number is 2298 when I try the (VBA code: Auto increment cell value after each printing:) it gives me 22981 how do I get it to 2298,2299,2300
    • To post as a guest, your comment is unpublished.
      tan chee ho · 7 months ago
      thank you very much, it works for me. And i manage to make a few minor change to suit my needs. Really Appreciate to your sharing.
    • To post as a guest, your comment is unpublished.
      skyyang · 8 months ago
      Hi, jennifer,
      To deal with your problem, please apply the following VBA code:
      Note: Please change the prefix text and number to your own.

      Sub IncrementPrint_Num()
      Dim xCount As Variant
      Dim xScreen As Boolean
      Dim I As Long
      Dim xStr As String
      Dim xInt As Integer
      On Error Resume Next
      xStr = "Company-" 'prefix text
      xInt = 2291 'number
      LInput:
      xCount = Application.InputBox("Please enter the number of copies you want to print:", "Kutools for Excel")
      If TypeName(xCount) = "Boolean" Then Exit Sub
      If (xCount = "") Or (Not IsNumeric(xCount)) Or (xCount < 1) Then
      MsgBox "error entered, please enter again", vbInformation, "Kutools for Excel"
      GoTo LInput
      Else
      xScreen = Application.ScreenUpdating
      Application.ScreenUpdating = False
      For I = 1 To xCount
      xInt = xInt + 1
      ActiveSheet.Range("A1").Value = xStr & xInt
      ActiveSheet.PrintOut
      Next
      ActiveSheet.Range("A1").ClearContents
      Application.ScreenUpdating = xScreen
      End If
      End Sub

      Please try it, hope it can help you!
      • To post as a guest, your comment is unpublished.
        Richard · 6 months ago
        Hello can you help me with this? I want the xINT to be more than 5 digits. Everytime i put a number with 6 digits, the count goes back to 1. How can i prevent that?
  • To post as a guest, your comment is unpublished.
    Desmond · 9 months ago
    thank you for posting this, it is very helpful. My question is this: I have 2 different barcodes that need to be incremented on one page, how can I modify the code to do that?
  • To post as a guest, your comment is unpublished.
    Pieter · 10 months ago
    thank you for the above, really helpful. is it possible to save and remember the last value
    • To post as a guest, your comment is unpublished.
      skyyang · 10 months ago
      Hello, Pieter,
      To save and remember the last printed value when you print next time, you should apply the following VBA code:

      Sub IncrementPrint()
      Dim xCount As Variant
      Dim xScreen As Boolean
      Dim I As Long
      Dim xM As Long
      Dim xMNWS As Worksheet
      Dim xAWS As Worksheet
      On Error Resume Next
      LInput:
      xCount = Application.InputBox("Please enter the number of copies you want to print:", "Kutools for Excel")
      If TypeName(xCount) = "Boolean" Then Exit Sub
      If (xCount = "") Or (Not IsNumeric(xCount)) Or (xCount < 1) Then
      MsgBox "error entered, please enter again", vbInformation, "Kutools for Excel"
      GoTo LInput
      Else
      xScreen = Application.ScreenUpdating
      Set xAWS = ActiveSheet
      On Error GoTo EMarkNumberSheet
      Set xMNWS = Sheets("IncrementPrint_MarkNumberSheet")
      EMarkNumberSheet:
      If xMNWS Is Nothing Then
      Set xMNWS = Application.Worksheets.Add(Type:=xlWorksheet)
      xMNWS.Name = "IncrementPrint_MarkNumberSheet"
      xMNWS.Range("A1").Value = 0
      xM = 0
      xMNWS.Visible = xlSheetVeryHidden
      Else
      xM = xMNWS.Range("A1").Value
      End If
      Application.ScreenUpdating = False
      For I = 1 To xCount
      xM = xM + 1
      xAWS.Range("A1").Value = " Company-00" & xM
      xAWS.PrintOut
      Next
      xMNWS.Range("A1").Value = xM
      xAWS.Range("A1").ClearContents
      Application.ScreenUpdating = xScreen
      End If
      End Sub

      If you need to reset the printed number to the default number, please run the below code firstly, and then execute the above code to print.

      Sub IncrementPrint_Reinstall()
      Dim xMNWS As Worksheet
      On Error GoTo EMarkNumberSheet
      Set xMNWS = Sheets("IncrementPrint_MarkNumberSheet")
      EMarkNumberSheet:
      If Not xMNWS Is Nothing Then
      Application.DisplayAlerts = False
      xMNWS.Visible = xlSheetHidden
      xMNWS.Delete
      Application.DisplayAlerts = True
      End If
      End Sub
  • To post as a guest, your comment is unpublished.
    Sniper · 1 years ago
    printed like 30 copies but now i cant print, runned the script a lot of times but not working, dont do anything :(
  • To post as a guest, your comment is unpublished.
    romik · 1 years ago
    my serial number start with 227861 how can i print from
  • To post as a guest, your comment is unpublished.
    Kris · 1 years ago
    Sorry to ask this on a separate post... My serial numbers start with a ZERO, but when I run the program it eliminates the zeros. I tried to convert the number field to text, but that did not fix it. Other ideas?
    • To post as a guest, your comment is unpublished.
      Art · 1 years ago
      R-Click Cell, Format, Custom, Where it says 'General', replace that with as many Zeros as your serial number will be. This will force the amount of zeros needed in front of your serial number. If I have a group of serial numbers that are 10 digit serials, I enter 0000000000 in the Type field to get '0004563571' to display in the serial number field.
      • To post as a guest, your comment is unpublished.
        Kris · 1 years ago
        Thank you Art. I did try that but the barcode kept eliminating the leading zeros... even after doing a custom number format.
  • To post as a guest, your comment is unpublished.
    Kris · 1 years ago
    Thank you for posting this, it is very helpful. My question is this: I have 2 different barcodes that need to be incremented on one page, how can I modify the code to do that?
  • To post as a guest, your comment is unpublished.
    Abdul · 1 years ago
    I need serial numbers like IA1-055242, IA1-055243, IA1-055244 .....
  • To post as a guest, your comment is unpublished.
    Kerry · 2 years ago
    This code is amazing, it is exactly what I need, however, I was wondering if there is a way to start printing from the number that is entered in cell "A1"?
    For example, if I have printed 100 copies, on the next print run I will need to print from number 101 and count up from there.
    I have tried a few code adjustments but it only seems to take the number entered in the cell i.e. 101, add 1 and then the rest of the prints are stuck with that one number, i.e. 102...

    Your assistance would be greatly appreciated :-)
    • To post as a guest, your comment is unpublished.
      Valentas · 1 years ago
      If you did't find a solution already you can edit line 17 of the code to this: ActiveSheet.Range("A1").Value = Range("A1").Value + 1
      This will ad +1 to the number you have in A1 cell.