Closed Thread
Results 1 to 6 of 6

Copy rows where date is equal TODAY and move them to another workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    7

    Copy rows where date is equal TODAY and move them to another workbook

    Hi,

    I would like to know if it is possible to use a macro that when a workbook closes, it saves all the rows where the date is equal TODAY into another workbook(either new or an existing workbook).

    Please guide me.

    Thanks

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy rows where date is equal TODAY and move them to another workbook

    Yes its possible. Why dont you give some more details with the help of a sample file?

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    08-13-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Copy rows where date is equal TODAY and move them to another workbook

    In the attached file(Form.xls) I have there date called field which when the date is equal to "8-24"(TODAY) all that have date called today will be transferred to an existing or new workbook, all rows included, and I will do that for all the sheets (client1, client2 and client3)

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim c As Range, LR As String, wbo As Workbook
    
    With Sheets("Client1")
        LR = .Range("A6555").End(xlUp).Row
        For Each c In .Range("G2:G" & LR).Cells
            If c.Value = VBA.Date Then
                c.EntireRow.Copy
                    
                    Set wbo = Workbooks.Open("C:\Documents\Files\transaction.xls ")
                    
                    With wbo.Sheets(1) 'with the past schools worksheet
                        LR = .Range("A6555").End(xlUp).Row + 1  
                            .Range("A" & LR).PasteSpecial   
                    End With
                c.EntireRow.Delete shift:=xlUp  
            End If
        Next c  
    End With
    Application.CutCopyMode = False 
    End Sub
    I found this code and tried to play with it, the code will transfer the copied rows to "transaction.xls" then will delete them on the main form. When I ran this code it gives me many errors.

    Please guide me.

    Thanks
    Brian
    Attached Files Attached Files
    Last edited by testingandroid; 08-24-2012 at 02:36 AM.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy rows where date is equal TODAY and move them to another workbook


  5. #5
    Registered User
    Join Date
    08-13-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Copy rows where date is equal TODAY and move them to another workbook

    Yes ma'am I'll mark this one as solved as well.

    Thanks

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy rows where date is equal TODAY and move them to another workbook

    Please ensure you do not create duplicate threads in future. You can bump a thread if you do not get replies.

    Also, marking it as "Solved" will continue to keep it as duplicate, so that doesnt help anything.

    Thread closed.

Closed Thread

Thread Information

Users Browsing this Thread

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

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