Author: Oscar Cronquist Article last updated on July 25, 2017

This post describes how to copy selected rows using checkboxes.

In a previous post I showed you how to add/remove checkboxes to a sheet:
Excel vba: Add checkboxes to a sheet (1/2)



VBA code

Sub CopyRows()

For Each chkbx In ActiveSheet.CheckBoxes
    If chkbx.Value = 1 Then
        For r = 1 To Rows.Count
            If Cells(r, 1).Top = chkbx.Top Then
                With Worksheets("Sheet2")
                    LRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
                    .Range("A" & LRow & ":D" & LRow) = _
                    Worksheets("Sheet1").Range("A" & r & ":D" & r).Value
                End With
                Exit For
            End If
        Next r
    End If

End Sub

Where to copy vba code?

  1. Copy above code
  2. Press Alt+F11 in excel
  3. Insert a module
  4. Paste code into code window
  5. Return to excel

I have assigned the macro to a button: Copy selected rows

  1. Go to Developer tab
  2. Click "Insert Controls" button
  3. Click "Button" button
  4. Create the button
  5. Select CopyRows macro
  6. Click OK!

Download excel file

Copy selected rows (checkboxes).xlsm