Excel Checkbox - How do i duplicate entire row when checkbox is ticked?

ozc1han

New Member
Joined
Jun 11, 2020
Messages
19
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

I've always found my answers to excel questions on mrexcel, however, at the moment I'm struggling! I'm not that experienced with Excel.

I have made a checklist with Check Boxes (Form Control), which is linked to the column beside it. When checked, TRUE appears in the column beside the checkbox and the checkbox highlights the row so it is clearly selected.

When checked I need the row to be duplicated (into another sheet [sheet 2]). When unchecked from sheet 2, I need to row be removed. Sheet 2 is basically going to be where I'd like all checked items from different sheets to appear.
If the row can't be duplicated, I would like it to be moved (into another sheet [sheet 2]).

Any help will be highly appreciated!

Thank you :)
 

Attachments

  • Capture.JPG
    Capture.JPG
    185.6 KB · Views: 30

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi, how can I edit my checklist to delete the row, once it has moved from the source sheet, to destination sheet?

The code can be found here:

Option Explicit

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If Not Intersect(Target, Range("G4:G2000")) Is Nothing Then
Application.EnableEvents = False

If ActiveCell.Value = ChrW(&H2713) Then
ActiveCell.clearcontents
ActiveCell.EntireRow.Interior.Color = xlNone
Else
ActiveCell.Value = ChrW(&H2713)
ActiveCell.EntireRow.Interior.ColorIndex = 2
End If
Application.ScreenUpdating = True

Cancel = True

End If

Application.EnableEvents = True

Copy_n_Paste

End Sub


Sub Copy_n_Paste()
On Error Resume Next

Dim srchtrm As String
Dim rng As Range, destRow As Long
Dim shtSrc As Worksheet, shtDest As Worksheet
Dim c As Range
Dim i As Integer
Dim Today As Date

With Application
.ScreenUpdating = False
.DisplayStatusBar = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With

Sheet11.Rows("16:2000").Delete

Set shtSrc = Sheets("Checklist") 'source sheet
Set shtDest = Sheets("Inspection Report") 'destination sheet
destRow = 16 'start copying to this row

'don't scan the entire column...
Set rng = Application.Intersect(shtSrc.Range("G:G"), shtSrc.UsedRange)

For Each c In rng.Cells
If c.Value = ChrW(&H2713) Then

c.EntireRow.Copy shtDest.Cells(destRow, 1)

destRow = destRow + 1

End If
Next

Sheet11.Columns("A:H").EntireColumn.AutoFit

Worksheets("Inspection Report").Range("A:A").ColumnWidth = 15
Worksheets("Inspection Report").Range("B:B").ColumnWidth = 28
Worksheets("Inspection Report").Range("C:C").ColumnWidth = 28
Worksheets("Inspection Report").Range("D:D").ColumnWidth = 28
Worksheets("Inspection Report").Range("E:E").ColumnWidth = 10
Worksheets("Inspection Report").Range("F:F").ColumnWidth = 0
Worksheets("Inspection Report").Range("G:G").ColumnWidth = 4
Worksheets("Inspection Report").Range("H:H").ColumnWidth = 0
Sheet11.Rows("16:2000").Rows.AutoFit


With Application
.ScreenUpdating = True
.DisplayStatusBar = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With

Application.CutCopyMode = False
Sheets("Operations - Data").Range("A1").Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top