Results 1 to 3 of 3

Thread: Copy data from a workbook to another according date entered

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0

    Copy data from a workbook to another according date entered

    In the attached sample Workbook GBook1.xls, and in Sheet1 the user enters a date in B1 and the data in each cell of range B3:C4.
    I want that data to be copied to another open Workbook (GBook2.xls) to the date entered in first Workbook, accordingly, when the user hits an OK button.
    Thanks in regands

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.eileenslounge.com/viewtopic.php?f=44&t=40455&p=313035#p313035
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312889#p312889
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312886#p312886
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312752#p312752
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312734#p312734
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312727#p312727
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312724#p312724
    https://www.eileenslounge.com/viewtopic.php?f=44&t=40374&p=312535#p312535
    https://www.eileenslounge.com/viewtopic.php?p=312533#p312533
    https://www.eileenslounge.com/viewtopic.php?f=44&t=40373&p=312499#p312499
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg. 9xhyRrsUUOM9xpn-GDkL3o
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=UgzlC5LBazG6SMDP4nl4AaABAg
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=UgzlC5LBazG6SMDP4nl4AaABAg. 9zYoeePv8sZ9zYqog9KZ5B
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg. 9xhyRrsUUOM9zYlZPKdOpm
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Attached Files Attached Files
    Last edited by DocAElstein; 03-01-2024 at 03:05 PM.

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Welcome to board.

    Put this code in a standard module on the GBook1.xls

    Code:
    Option Explicit
    Sub kTest()
        
        Dim wbkFrom As Workbook
        Dim wbkTo   As Workbook
        Dim f, d    As Long
        
        On Error Resume Next
        
        Set wbkFrom = ThisWorkbook
        Set wbkTo = Workbooks("GBook2.xls")    '<< adjust the name
        
        On Error GoTo 0
        If wbkTo Is Nothing Then
            MsgBox "Open the other workbook first", vbInformation
            Exit Sub
        End If
        d = wbkFrom.Worksheets(1).Range("b1") '<< date
        
        f = Evaluate("match(" & d & "," & wbkTo.Worksheets(1).Columns(1).Address(external:=1) & ",0)")
        
        If Not IsError(f) Then
            With wbkTo.Worksheets(1).Range("b" & f)
                .Resize(, 3).Value = wbkFrom.Worksheets(1).Range("b3:d3").Value2
                .Offset(, 3).Resize(, 3).Value = wbkFrom.Worksheets(1).Range("b4:d4").Value2
            End With
            MsgBox "Done"
        Else
            MsgBox "Date '" & CDate(d) & "' could not be found", vbInformation
        End If
        
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0
    It's OK. Thank you for your help.

Similar Threads

  1. Replies: 2
    Last Post: 09-18-2013, 12:30 AM
  2. Lock Cells After Data Entered
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 4
    Last Post: 06-28-2013, 10:52 PM
  3. Replies: 2
    Last Post: 05-28-2013, 05:32 PM
  4. Replies: 0
    Last Post: 04-20-2013, 10:07 AM
  5. VBA code to copy data from source workbook
    By Howardc in forum Excel Help
    Replies: 1
    Last Post: 07-30-2012, 09:28 AM

Tags for this Thread

Posting Permissions

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