Note: The other languages of the website are Google-translated. Back to English
Iniciar sesión  \/ 
x
or
x
Inscríbete  \/ 
x

or

¿Cómo hacer doble clic en una celda y agregar 1 a ese valor de celda en Excel?

Este artículo le mostrará el método de agregar 1 a un valor de celda automáticamente haciendo doble clic en Excel.

Haga doble clic en una celda y agregue 1 con código VBA


Haga doble clic en una celda y agregue 1 con código VBA


El siguiente código VBA puede ayudarlo a agregar 1 a un valor de celda después de hacer doble clic. Haz lo siguiente.

1. Haga clic con el botón derecho en la pestaña de la hoja cuyos valores de celda necesita agregar 1 haciendo doble clic. Luego haga clic en Ver código desde el menú contextual.

2. En la aparición Microsoft Visual Basic para aplicaciones ventana, copie y pegue el siguiente código VBA en la ventana Código.

Código VBA: agregue 1 a un valor de celda haciendo doble clic

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    If Not Intersect(Target, Range("A1")) Is Nothing Then
      Range("A1").Value = Range("A1").Value + 1
      Cancel = True
    End If
End Sub

Nota:: En el código, A1 es la celda a la que agregará el número 1 haciendo doble clic.

3. presione el otro + Q teclas simultáneamente para cerrar la ventana de Microsoft Visual Basic para Aplicaciones.

Ahora, haga doble clic en la celda A1 y agregará 1 al valor existente como se muestra a continuación.


Artículos relacionados:


Las mejores herramientas de productividad de oficina

Kutools para Excel resuelve la mayoría de sus problemas y aumenta su productividad en un 80%

  • Reutilizar: Inserte rápidamente fórmulas complejas, gráficos y cualquier cosa que hayas usado antes; Cifrar celdas con contraseña; Crear lista de distribución y enviar correos electrónicos ...
  • Barra de súper fórmula (edite fácilmente varias líneas de texto y fórmulas); Diseño de lectura (leer y editar fácilmente un gran número de celdas); Pegar en rango filtrado...
  • Combinar celdas / filas / columnas sin perder datos; Contenido de celdas divididas; Combinar filas / columnas duplicadas... Prevenir celdas 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 Varias celdas sin cambiar la referencia de la fórmula; Crear referencias automáticamente a varias hojas; Insertar viñetas, Casillas de verificación y más ...
  • Extraer texto, Agregar texto, Eliminar por posición, Quitar espacio; Crear e imprimir subtotales de paginación; Convertir entre contenido de celdas y comentarios...
  • Súper filtro (guardar y aplicar esquemas de filtros a otras hojas); Orden avanzado por mes / semana / día, frecuencia y más; Filtro especial en negrita, cursiva ...
  • Combinar libros y hojas de trabajo; Combinar tablas basadas en columnas clave; Dividir datos en varias hojas; Conversión por lotes de xls, xlsx y PDF...
  • Más de 300 potentes funciones. Compatible con Office / Excel 2007-2019 y 365. Compatible con todos los idiomas. Fácil implementación en su empresa u organización. Características completas Prueba gratuita de 30 días. Garantía de devolución de dinero de 60 días.
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

  • Habilite la edición y lectura con pestañas en Word, Excel, PowerPoint, Publisher, Access, Visio y Project.
  • Abra y cree varios documentos en nuevas pestañas de la misma ventana, en lugar de en nuevas ventanas.
  • ¡Aumenta su productividad en un 50% y reduce cientos de clics del mouse todos los días!
officetab parte inferior
Say something here...
symbols left.
You are guest
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.
    OW · 10 months ago
    What code would I you if I want to add 1 to multiple cells lets say E5:E15 but then add .5 or a different number to another group of cells like G5:515?
  • To post as a guest, your comment is unpublished.
    Stella · 1 years ago
    I cannot get this to work in multiple cells
    Tried using, but it did not work


    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    If Not Intersect(Target, Range("B2:L14")) Is Nothing Then
    Range("B2:L14").Value = Range("B2:L14").Value + 1
    Cancel = True
    End If
    End Sub
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Stella,
      Please apply the below VBA to solve the problem.

      Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
      On Error Resume Next
      If Not Intersect(Target, Range("B2:L14")) Is Nothing Then
      Target.Value = Target.Value + 1
      Cancel = True
      End If
      End Sub
  • To post as a guest, your comment is unpublished.
    Bill · 3 years ago
    If you want to increment any cell in a workbook cell by double clicking on that cell but only that cell, this code works:

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    If Not Intersect(Target, Range(ActiveCell.Address)) Is Nothing Then
    ActiveCell.Value = ActiveCell.Value + 1
    Cancel = True
    End If
    End Sub
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Bill,
      Thank you for sharing.
      • To post as a guest, your comment is unpublished.
        BB · 3 years ago
        Thank You! that helped me a lot!
  • To post as a guest, your comment is unpublished.
    Steve · 3 years ago
    This is great! How do I do this for multiple cells? I type in "A1,A2" instead "A1", it makes both cells equal and adds 1 to both cells simultaneously. I'd like the cells to act independently.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Sorry I didn’t get your point.
      • To post as a guest, your comment is unpublished.
        Adam · 3 years ago
        Hello - agree with Steve this is great. I think what he would like (and me too) is to be able to add to the value of multiple different cells in the same tab by double clicking on them. He has amended the VBA formula so it says "A1,A2" instead of just "A1" however double clicking on "A1" adds 1 to both cells. Is it possible to change the formula so that multiple cells are included with the value of each only being increased when you click on it directly?
        • To post as a guest, your comment is unpublished.
          laura · 3 years ago
          maybe by making a table with a range name. and updating the formula to include that?
        • To post as a guest, your comment is unpublished.
          Steve · 3 years ago
          Basically, with the code above, if you double clicked on A1, it would add 1 to A1. If I changed A1 to A1:A2 in the Target Range, then if I double clicked on A1 or A2, it would add 1 to A1. What I wanted was to add 1 to A1 only if I double clicked on A1, and add 1 to A2 only if I double clicked on A2. I also did not want to add 1 to both cells.

          I think I have found what I was looking for:

          Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
          If Not Intersect(Target, Range("D5:BC56")) Is Nothing Then
          Cancel = True
          Range(Target.Address).Value = Val(Range(Target.Address).Value) + 1
          End If
          End Sub
          • To post as a guest, your comment is unpublished.
            Sophie · 3 years ago
            This code does not seem to work for me. Don't I have to specify which is the Target.Adress ?
          • To post as a guest, your comment is unpublished.
            crystal · 3 years ago
            Dear Steve,
            I got your point finally, and thank you for sharing.
  • To post as a guest, your comment is unpublished.
    Matt · 3 years ago
    Can we add a two digit number to the end of the date? for example i need to double click and add the current date and the next two digit number (20171030-01 then the next cell will show 20171030-02 upon double click)
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Matt,
      The code only supports the number format cell. It can't work as your data 20171030-01 is text format. Sorry about that.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Matt,
      The code only supports the number format cell. It can work as your data 20171030-01 is a text format. Sorry about that.