Forum Discussion
Copy highlighted rows and paste into new sheet
- Jul 01, 2022
I'm afraid that having more than 10,000 check boxes has an enormous negative impact on performance. Even opening the workbook was very slow.
I replaced the check boxes with "x"es in column A. The copy code can then use AdvancedFilter.
Is created a criteria range in K1:K2, and copied the headers in B1:AI1 manually to Sheet2. The code can then be:
Private Sub CommandButton3_Click() Dim LastRow As Long LastRow = Range("A" & Rows.Count).End(xlUp).Row Range("A1:AI" & LastRow).AdvancedFilter _ Action:=xlFilterCopy, _ CriteriaRange:=Range("AK1:AK2"), _ CopyToRange:=Worksheets("Sheet2").Range("B1:AI1") End SubThe code runs in a handful of seconds on my PC.
See the attached version.
I'm afraid that having more than 10,000 check boxes has an enormous negative impact on performance. Even opening the workbook was very slow.
I replaced the check boxes with "x"es in column A. The copy code can then use AdvancedFilter.
Is created a criteria range in K1:K2, and copied the headers in B1:AI1 manually to Sheet2. The code can then be:
Private Sub CommandButton3_Click()
Dim LastRow As Long
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:AI" & LastRow).AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=Range("AK1:AK2"), _
CopyToRange:=Worksheets("Sheet2").Range("B1:AI1")
End Sub
The code runs in a handful of seconds on my PC.
See the attached version.