+ Reply to Thread
Results 1 to 8 of 8

Copy Paste data after specific Time Interval

Hybrid View

  1. #1
    Registered User
    Join Date
    12-23-2016
    Location
    India
    MS-Off Ver
    2007-2010
    Posts
    29

    Copy Paste data after specific Time Interval

    Hi Friends

    I need one vba macro to copy paste data after specific time interval.....say in H1 cell has time 7:00:00 (or time between 7:00:00 to 7:01:00) then just copy data to cell D3:D5 from Cell J1:J3. attached excel workbook for reference.

    see below snapshot for further information.

    Capture.PNG

    Thanks in advance
    Enroll
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Copy Paste data after specific Time Interval

    Hi,
    You could use Application.OnTime.
    After button will be pressed application will take time from cell H1 and run CopyValues sub in this time.

    Sub Button1_Click()
    
    Application.OnTime Sheets("Sheet1").Range("H1"), "CopyValues"
    
    End Sub
    
    
    Sub CopyValues()
    
    Sheets("Sheet1").Range("D3:D5").Copy Sheets("Sheet1").Range("J1")
    
    End Sub
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    12-23-2016
    Location
    India
    MS-Off Ver
    2007-2010
    Posts
    29

    Re: Copy Paste data after specific Time Interval

    Hi Kasan,

    Thanks for your help, however it's not working...i just need copy data from J1:J3 to
    Say if H1 having time 7:00:00AM then paste data in D3:D5
    Say if H1 having time 9:00:00AM then paste data in D11:D13

    It would be very helpful if you do automatic process without any interpretation.

    Thanks in advance

  4. #4
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Copy Paste data after specific Time Interval

    Hi,
    Slightly changed code. Now values from range J1:J3 will be copied to column D to the right from according time.
    Make sure that time in H1 is in column B, if not - you will see message box and nothing will happen.

    Sub Button1_Click()
    
    If IsError(Application.Match(Sheets("Sheet1").Range("H1"), Sheets("Sheet1").Range("B:B"), 0)) Then
        MsgBox "No time found in table"
        Exit Sub
    End If
    
    Application.OnTime Sheets("Sheet1").Range("H1"), "CopyValues"
    
    End Sub
    
    
    Sub CopyValues()
    
    Sheets("Sheet1").Range("J1:J3").Copy Sheets("Sheet1").Range("D" & Application.Match(Sheets("Sheet1").Range("H1"), Sheets("Sheet1").Range("B:B"), 0))
    
    End Sub
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-23-2016
    Location
    India
    MS-Off Ver
    2007-2010
    Posts
    29

    Re: Copy Paste data after specific Time Interval

    Hi Kasan

    Amazing....perfectly working. Can we run above code by every 15 minutes.

    Thank you so much

    Reputation added.

  6. #6
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Copy Paste data after specific Time Interval

    You can run this code every 15 minutes. What values will be changed for each run? will you change time in H1 for every run?
    Describe your idea more in detail and step-by-step and we will figure out something.

  7. #7
    Registered User
    Join Date
    12-23-2020
    Location
    Amdavad
    MS-Off Ver
    2016
    Posts
    1

    Re: Copy Paste data after specific Time Interval

    Thanks Kasan for your valuable inputs.
    Further to this discussion i would like if you can add some code for timer or something like that to copy data from one sheet to another to use in chart.
    For Example if we download data from certain stock broking website where price is changing frequently.Can we we copy this scrap data to another file on every five minute?

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Copy Paste data after specific Time Interval

    Quote Originally Posted by Bharatkshatriya View Post
    Thanks Kasan for your valuable inputs.
    Further to this discussion i would like if you can add some code for timer or something like that to copy data from one sheet to another to use in chart.
    For Example if we download data from certain stock broking website where price is changing frequently.Can we we copy this scrap data to another file on every five minute?
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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. Copy and Paste done at time interval
    By mcp77 in forum Excel General
    Replies: 5
    Last Post: 10-20-2016, 10:56 AM
  2. Copy and Paste down at time interval
    By mcp77 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2016, 02:51 AM
  3. Replies: 1
    Last Post: 04-29-2014, 04:42 AM
  4. Macro to copy and paste at specific time of day
    By BCrawford in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2013, 06:27 AM
  5. interval in specific time
    By pan_arshad in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-18-2012, 04:19 AM
  6. Replies: 5
    Last Post: 05-01-2012, 04:27 PM
  7. Replies: 0
    Last Post: 04-23-2012, 10:06 AM

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