title: Adding Checkboxes next to pivot table that are added until the last row of information in the pivot table
body: <p>Dear all: I need to add check boxes to column A, that is to the left of my pivot table, starting form column B to column D. I also want that the check boxes are linked to the extreme right of the pivot table, that is to say column E.</p>
  
  <p>I have found a code that does that. However it is limited to a specific range ("A4:A9"). I wanted that the code was able to add check boxes regardless of the length of the pivot table dynamically in case it grows in other words to the last row.</p>
  
  <p>Please find attached the whole code that I have already </p>
  
  <pre><code>Sub AddCheckBox()
      Dim cell As Range
  
      DelCheckBox  'Do the delete macro
      'or delete all checkboxes in the worksheet
      ' ActiveSheet.CheckBoxes.Delete
      Dim MyRow As Long
  
      lastrow = Cells.Find("*", Range("A1"), xlValues, , xlByRows, xlPrevious).Row
  
      For Each cell In Range("A4:A9")
          With ActiveSheet.CheckBoxes.Add(cell.Left, _
              cell.Top, cell.Width, cell.Height)
              .LinkedCell = cell.Offset(, 4).Address(External:=True)
              .Interior.ColorIndex = 37   'or  xlNone or xlAutomatic
              .Caption = ""
              '.Border.Weight = xlThin
          End With
      Next
  
      With Range("A4:A9")
          .Rows.RowHeight = 15
      End With
  End Sub
  </code></pre>
  
  <hr>
  
  <pre><code>Sub DelCheckBox()
      For Each cell In Range("A4:A9")
          Worksheets("Analysis").CheckBoxes.Delete
      Next
  End Sub
  </code></pre>
  
  <p>I have found a code that identifies the last row. However, I must be doing something wrong because It doesn't seem to work when I try to insert it with the rest of the code. In fact, I don't know where I need to insert it for it to work properly. Could anyone help me please to identify what I need to do?</p>
  
  <p>Many thanks in advance for all your help.</p>