Delete Rows based on date

ai1094

Board Regular
Joined
Aug 23, 2018
Messages
92
Hi,

I have a spreadsheet containing current month and last month data. My goal is to create a macro to delete the last month of data and then point to a new workbook to copy and paste the new current month data into the existing workbook. Is there a simple VBA code to create this?

For example:

I have April data
I have May data
(both consolidated into one sheet)

I want the macro to look for April data, delete all rows and point to the June data workbook, copy and paste the data into the existing workbook.

Would appreciate any help I could get. Thanks!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Do you want to point to a new workbook (open it) or do you want to copy the sheet to a new workbook and save it as next month's?

In which column do you have the dates?
What is the sheet name?
what is the workbook name?

Another question: why are there april & May data in the May workbook? why not only May data to start with?
 
Upvote 0
I want it to point to a workbook with the new month's data and copy and paste that into the first existing workbook.

The dates are in column C
Sheet name is "Sheet2"
Workbook name is "SpaceAllocationsSnapshot"

And to answer your additional question, I get an extract of the data when the new month occurs and that workbook already contains previous month and current month.


Do you want to point to a new workbook (open it) or do you want to copy the sheet to a new workbook and save it as next month's?

In which column do you have the dates?
What is the sheet name?
what is the workbook name?

Another question: why are there april & May data in the May workbook? why not only May data to start with?
 
Upvote 0
Maybe I did not put my questions right:

The extract comes into workbook1, into SheetX, starting from cell A1
What is the name of workbook1, SheetX?

The filtered data need to go to workbook2, into SheetY starting from cell An
What is the name of workbook2 (does that change every month?)
What is the name of SheetY (does that change every month?)
Which cell does it go into? Or is it added to the bottom?
Is this transfer done once a month, so the whole new month is added, or does the macro need to check which dates already exist in the sheet and only add newer rows?

Where do you want to have the macro: in workbook1, in workbook2 or in a separate workbook that manages both inpput and output workbooks?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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