+ Reply to Thread
Results 1 to 3 of 3

Marco for copying data, clearing data, moving data.

Hybrid View

  1. #1
    Registered User
    Join Date
    09-15-2021
    Location
    USA
    MS-Off Ver
    Office365
    Posts
    34

    Marco for copying data, clearing data, moving data.

    I am looking for a macro that would do the following:

    On specific date or say the 25th of each month if the spreadsheet is opened up the macro would copy A1-A14:L1-L14 then paste it in a specific workbook name PR. Each month it would make sure to just copy and paste under the previous months data. Then the macro would take H2:H14 and copy the current values to G2:G14 then save the file.



    Basically I am trying to move data to another workbook for tracking and history and then use the main workbook for a month tracker with updated data.

    Is this something I can get help writing or can you point me in the direction of where I could find some information to achieve this goal?

  2. #2
    Forum Contributor
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    121

    Re: Marco for copying data, clearing data, moving data.

    VBA can do this for sure. You'll want to use Workbook_Open() and check today's date to see if it is the 25th (what happens if you open the file multiple times on the 25th?)

        If Day(Date()) = 25 then CopyData()
    CopyData being the sub procedure with the actual code to copy and range data to the other workbook. Then delete the data in the current workbook.
    https://www.exceldemy.com/excel-vba-...ther-workbook/

    edit: fixed if statement, Day function

    edit 2: Also, once you have some code, if you run into any issues, post your code with what issue you're having and where it is happening.
    Last edited by jdelano; 04-20-2024 at 06:13 AM.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: Marco for copying data, clearing data, moving data.

    This will give you an idea...
    You did not stipulate where the data A1:L14 is to be pasted in PR workbook...
    Below code assumes Col A...
    Sub Auto_Open()
    Dim Path As String, Rng As Range
    Path = ThisWorkbook.Path & "\" '! Change to Path housing PR book...
    Set Rng = Range("A1:L14")
    If Format(Date, "dd") = 20 Then '! Change to day required...
        With Workbooks.Open(Path & "PR.xlsx")
            Rng.Copy .ActiveSheet.Range("A" & Rows.Count).End(xlUp)(2)
            .Save
            .Close False
        End With
    End If
    Range("H2:H14").Copy Range("G2")
    ActiveWorkbook.Save
    End Sub
    Attached Files Attached Files
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 11-04-2018, 09:08 AM
  2. Replies: 9
    Last Post: 11-04-2018, 07:12 AM
  3. Finding and Copying/Moving Data
    By BeerStud in forum Excel General
    Replies: 1
    Last Post: 09-07-2017, 07:41 AM
  4. [SOLVED] Copying data entries in one row, to separate rows, while also moving their auxiliary data
    By bqeuux in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-20-2015, 11:52 AM
  5. Using Marco - moving a line of data..
    By matt_boy83 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-04-2014, 07:36 AM
  6. Copying Data from one sheet to another and moving sheets as data changes
    By munson442 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-06-2013, 06:18 PM
  7. Copying and Moving Data
    By j-stad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2010, 01:34 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1