Thread: [Solved] Copy Paste Rows
View Single Post
 
Old 10-16-2024, 06:17 AM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 587
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default Copy Paste Rows

Cross posted at : Copy Paste Rows


My project requires copying rows with CheckBoxes marked as TRUE beginning at row 11 and down to rows used. Then pasting those rows
to a second sheet, beginning at row 1 in Column A.

Here is my attempt at doing so. The issue I am running into is getting the macro to identify the first row with a "True" checkbox in Column E.
I don't know if the copy/paste will function as desired as my current macro doesn't do anything. No errors / no remarks ... it just quickly goes
through whatever motions it is going through, stops but nothing is copied or pasted.

Thank you for your assistance.

Code:
Copy to clipboard
Sub CopyRows()
Dim chkbx As CheckBox
Dim r As Long
Dim LRow As Long


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

End Sub
Here is the range affected with the above macro (attached).

Workbook file is attached as well.
Attached Images
File Type: jpg Copy Paste.jpg (51.5 KB, 11 views)
Attached Files
File Type: xlsm Copy Paste.xlsm (21.0 KB, 2 views)
Reply With Quote