Delete Rows based on date

ai1094

Board Regular
Joined
Aug 23, 2018
Messages
90
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!
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

sijpie

Well-known Member
Joined
Nov 1, 2008
Messages
3,661
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?
 

ai1094

Board Regular
Joined
Aug 23, 2018
Messages
90
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?
 

sijpie

Well-known Member
Joined
Nov 1, 2008
Messages
3,661
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,101,819
Messages
5,483,084
Members
407,379
Latest member
Bender1964

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top