VBA macro to transfer data based on date

RockstarJim

New Member
Joined
Aug 22, 2018
Messages
5
Hello all,

I have data for projects on a sheet named Master with several target dates. What I am wanting to do is transfer all data within that row to another sheet named Past Due, when the date in column F surpasses "todays" date. I would like this to happen automatically at midnight, but if that is not possible I could do it using a commend button.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Sounds like this should be run from the Windows Task Scheduler.
1. Setup a PowerShell script to run Excel macro
2. Create a .bat file to run the PowerShell script
3. Create a basic task in the Windows Task Scheduler to run the .bat to run at the specific time
 
Upvote 0
So this is what I got so far, but will not work with the correct date. column F holds the target date, and if that target date has passed "today's" date, it should copy the complete row to the past_due sheet.

Private Sub CommandButton1_Click()


Dim rng As Range
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet


Set pasteSheet = Worksheets("Past_Due")
Set rng = Range("A4").CurrentRegion
Set rng = rng.Offset(1, 0)


If Sheets(Master).Cells(F, Column).Value <= today Then
Sheets(Past_Due).Rows(F).EntireRow.Hidden = False
End If


rng.Copy
pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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