Hello,
I have this code to cut a row from one sheet to another, if the checkbox exists in front of that row,
I want to make it work if the checkbox exists and is checked if possible
Something like
The problem is that when i click on a checkbox using the other code, it's cutting all rows that has checkboxes infront of them starting from one i checked till the last row containing checkbox
I have this code to cut a row from one sheet to another, if the checkbox exists in front of that row,
I want to make it work if the checkbox exists and is checked if possible
Something like
VBA Code:
If ChkBx.Value = 1 & CB.Value = xlOn Then
Code:
Sub CopyRows()
Dim ws1 As Worksheet
Set ws1 = Worksheets("Sheet1")
Dim ws2 As Worksheet
Set ws2 = Worksheets("Sheet2")
Dim LRow As Long
LRow = ws2.Range("A" & Rows.Count).End(xlUp).Row
Dim r As Long
Dim ChkBx As CheckBox
For Each ChkBx In ws1.checkboxes
If ChkBx.Value = 1 Then
LRow = LRow + 1
r = ChkBx.TopLeftCell.Row
ws2.Range("A" & LRow & ":E" & LRow).Value = _
ws1.Range("A" & r & ":E" & r).Value
End If
Next
End Sub