VBA Code to be completed with actual date

caos88

Board Regular
Joined
Mar 12, 2020
Messages
66
Office Version
  1. 2010
Platform
  1. Windows
Good Afternoon,

i currently have the below code to cut and paste rows from Sheet 1 to final sheet. However, i was wondering if, together with this operation, is possible to include the date when the row will actually be moved to the final sheet. Code has been given from you guys....in another threads.
Any idea about it ?

Thank you


Sub Cut()

Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet


' Change worksheet designations as needed
Set Source = ActiveWorkbook.Worksheets("Sheet1")
Set Target = ActiveWorkbook.Worksheets("Final_sheet")

j = Target.Range("A" & Rows.Count).End(xlUp).Row + 1 ' Start copying 1 down from the last row on sheet
For Each c In Source.Range("I1:I1000") ' Do 1000 rows
If c = "Proceed" Then
Source.Rows(c.Row).Copy Target.Rows(j)
Source.Rows(c.Row).Cut Target.Rows(j)
j = j + 1

End If
Next c
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
This will place the date in column "M" on the Target sheet

VBA Code:
Sub Cut()
    Dim c As Range
    Dim j As Integer
    Dim Source As Worksheet
    Dim Target As Worksheet
        
    ' Change worksheet designations as needed
    Set Source = ActiveWorkbook.Worksheets("Sheet1")
    Set Target = ActiveWorkbook.Worksheets("Final_sheet")
    
    j = Target.Range("A" & Rows.Count).End(xlUp).Row + 1 ' Start copying 1 down from the last row on sheet
    For Each c In Source.Range("I1:I1000") ' Do 1000 rows
        If c = "Proceed" Then
            'Source.Rows(c.Row).Copy Target.Rows(j)
            Source.Rows(c.Row).Cut Target.Rows(j)
            Target.Range("M" & j).Value = Date
            j = j + 1
        End If
    Next c
End Sub
 
Upvote 0
This will place the date in column "M" on the Target sheet

VBA Code:
Sub Cut()
    Dim c As Range
    Dim j As Integer
    Dim Source As Worksheet
    Dim Target As Worksheet
       
    ' Change worksheet designations as needed
    Set Source = ActiveWorkbook.Worksheets("Sheet1")
    Set Target = ActiveWorkbook.Worksheets("Final_sheet")
   
    j = Target.Range("A" & Rows.Count).End(xlUp).Row + 1 ' Start copying 1 down from the last row on sheet
    For Each c In Source.Range("I1:I1000") ' Do 1000 rows
        If c = "Proceed" Then
            'Source.Rows(c.Row).Copy Target.Rows(j)
            Source.Rows(c.Row).Cut Target.Rows(j)
            Target.Range("M" & j).Value = Date
            j = j + 1
        End If
    Next c
End Sub

Hello @sericom . That works perfectly !!! thank you
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,049
Members
449,206
Latest member
Healthydogs

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