Delete Rows based on date
Results 1 to 4 of 4

Thread: Delete Rows based on date
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Aug 2018
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Delete Rows based on date

    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!

  2. #2
    Board Regular
    Join Date
    Nov 2008
    Location
    Netherlands
    Posts
    3,402
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Delete Rows based on date

    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?
    Short Guide to Better VBA - Link: https://www.mrexcel.com/forum/showthread.php?t=712119

    Please use code tags around your code:
    [Code] Your code here... [/Code]




    Engelse lessen, persoonlijk en doelgericht. Dutch tuition tailor-made for you. https://Ennef.nl

    Wearable for people with panic attacks: sidjup https://sidjup.com

  3. #3
    Board Regular
    Join Date
    Aug 2018
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Delete Rows based on date

    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.


    Quote Originally Posted by sijpie View Post
    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?

  4. #4
    Board Regular
    Join Date
    Nov 2008
    Location
    Netherlands
    Posts
    3,402
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Delete Rows based on date

    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?
    Short Guide to Better VBA - Link: https://www.mrexcel.com/forum/showthread.php?t=712119

    Please use code tags around your code:
    [Code] Your code here... [/Code]




    Engelse lessen, persoonlijk en doelgericht. Dutch tuition tailor-made for you. https://Ennef.nl

    Wearable for people with panic attacks: sidjup https://sidjup.com

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •