VBA code to Move entire row if checkbox is checked and also date stamp

Penni

New Member
Joined
Mar 18, 2020
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
This is my first post so bear with me if it is not perfect :)

If checkbox is checked VBA date stamps it with today's date and moves the entire row from worksheet "New Client" to another worksheet "Complete NC"
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
VBA Code:
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, 1).Top = chkbx.Top Then
                With Worksheets("Complete NC")
                    LRow = .Range("B" & Rows.Count).End(xlUp).Row + 1
                    .Range("B" & LRow) = Date
                    .Range("B" & LRow & ":D" & LRow) = Worksheets("New Clients").Range("A" & r & ":D" & r).Value
                    .Range("A" & LRow) = Format(Now, "mm-dd-yyyy")
                End With
                Exit For
            End If
        Next r
    End If
Next

End Sub

Download example workbook : Internxt Drive – Private & Secure Cloud Storage
 
Upvote 0
@Logit, your example file is pretty flash.

You might want to make a couple of changes:
Rich (BB code):
                    .Range("A" & LRow) = Date                                                                       ' Change to column A
                    .Range("B" & LRow & ":E" & LRow) = Worksheets("New Clients").Range("A" & r & ":D" & r).Value    ' Expand Target to E
                    .Range("A" & LRow) = Format(Now, "mm-dd-yyyy")                                                  ' Remove this or .Range("A" & LRow).NumberFormat = "mm-dd-yyyy"
 
Upvote 0
Alex : Thank you for the heads up. Somehow I managed to copy the wrong macro to paste here. This is the correct macro ...

VBA Code:
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, 1).Top = chkbx.Top Then
                With Worksheets("Complete NC")
                    LRow = .Range("B" & Rows.Count).End(xlUp).Row + 1
                    .Range("A" & LRow) = Date
                    .Range("B" & LRow & ":E" & LRow) = Worksheets("New Clients").Range("A" & r & ":D" & r).Value
                    .Range("A" & LRow).NumberFormat = "mm-dd-yyyy"
                End With
                Exit For
            End If
        Next r
    End If
Next
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,025
Members
452,542
Latest member
Bricklin

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