Add a variable number of rows based on a checkbox

Dzen -  
 Dzen -
Hello,

I would like to create a macro that automatically generates a number of rows in a table based on a cell where I will enter the number.
Another question, is it possible to automatically create, with VBA, a vertical addition of cells in a column? This way, I could add a different number in each column, and if possible, with text customization. Then, the end user could fill them in.
I hope my explanation is sufficient. I should mention that I am a complete beginner in programming.
Thank you for your help.

Configuration: Macintosh / Chrome 87.0.4280.67

1 answer

  1. cs_Le Pivert Posted messages 8437 Status Contributor 730
     
    0
    1. Dzen
       
      merci mais comment je peux personnaliser que le nombre de lignes à insérer soit dépendant d'une case dans le fichier?
      0
    2. cs_Le Pivert Posted messages 8437 Status Contributor 730 > Dzen
       
      Go to the relevant sheet and press Alt F11 to access the sheet module

      The macro will trigger on double-clicking the cell containing the number of rows to add, in this case C1

      Option Explicit Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Dim myCell, col, ligne If Not Application.Intersect(Target, Range("C1")) Is Nothing Then Set myCell = Application.InputBox( _ prompt:="Select the starting cell", Type:=8) col = myCell.Column ligne = myCell.Row ActiveSheet.Range(ActiveSheet.Cells(ligne, col), ActiveSheet.Cells(ligne + Target.Value, col)).EntireRow.Insert End If End Sub 



      That's all very simple

      @+
      0
    3. Dzen > cs_Le Pivert Posted messages 8437 Status Contributor
       
      Good evening,
      I put it in the macro, I placed it in cell D27 (the cell where I enter my value) but nothing happens. I don't know how to do it because I've never used macros. I don't understand how the "select starting cell" button works.

      In fact, I'm not sure if it's clear but the number of cells to be entered in column A (of sheet 1) is found in another sheet (sheet 2 cell B1) but then, I would like to do the same thing with column B (number in sheet 2 cell D1) and do that two more times.

      Thank you for your help.
      0
    4. Dzen > cs_Le Pivert Posted messages 8437 Status Contributor
       
      Je suis désolé, mais je ne peux pas accéder aux liens ou au contenu externe. Veuillez fournir le texte que vous souhaitez traduire.
      0