+ Reply to Thread
Results 1 to 35 of 35

Every 1 hour data should copy paste from A to B, then A to C and so on

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Every 1 hour data should copy paste from A to B, then A to C and so on

    hello,

    I have a Product list in Column which every hour "A" with conditionally formatting red and green (red = sold, green = purchase) which every hour needs to record manually in column B then C then D, and so on

    need your help with VBA code or formula so can do this automatically

    Product list
    A B C D E
    1 Fan
    2 Switch
    3 Wire
    4 tapes
    5 pins
    6 sockets
    7 board
    8
    9
    10
    11

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Try application.Ontime to run sub after 1 hour
    LIke this:
    PHP Code: 
    Sub Timer()
    application.ontime Now timevalue("01:00:00"), "MainSub"
    End sub
    '----------------------
    Sub MainSub()
    <Your main code here>
    End sub 
    Quang PT

  3. #3
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Thank for a quick reply.

    Should I paste this code into the VBA code view in excel??
    How will my data will paste from column A to B then A to C then A to D and so on every hour

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Could you post a image/screenshot of sample worksheet?
    I dont know how to define the last column to paste column A into after each hour. Are there any data in other column to the right. i.e, AA or AB,...?

  5. #5
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Attachment 789739

    please check have uploaded a screenshot

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Invalid Attachment.
    Try again.

  7. #7
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Please check have reuploaded. Thank you
    Attached Images Attached Images

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Please attach the workbook, NOT a picture of it!
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    ok Thank you

  10. #10
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Hi,

    Uploaded excel sheet for your reference.
    Attached Files Attached Files

  11. #11
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Maybe below code pasted into module

    PHP Code: 
    Option Explicit
    Public As Long
    ' set timer
    Sub timer()
    t = Hour(TimeValue(Now)) + 1
    set next run time to next hour from nowstop at 17h
    Application
    .OnTime Date 24"copyRng"Date 17 24
    End Sub
    Sub copyRng
    ()
    Dim lr&, copyRng As RangepasteRng As Range
    lr 
    Cells(Rows.Count"A").End(xlUp).Row
    Hour(TimeValue(Now)) 'current hour
    Set copyRng = Range("A6:A" & lr)
    On Error Resume Next
    Set pasteRng = Range("A6").Offset(0, t - 6)
    Range("A6:A" & lr).copy pasteRng
    pasteRng.EntireColumn.AutoFit
    On Error GoTo 0
    End Sub 

  12. #12
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Thank you thank you thank you. you are a genius. Superb Fantabulous

  13. #13
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Bro one more help, please

    If the timer will start exactly 8:00 AM and
    Can we convert hours to minutes

    Thank you

  14. #14
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Could you give a sample with minute?

  15. #15
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Instead of 1 hour will it be possible to make 15 minutes or 30 minutes
    Like
    Starting Time 8:00 AM than next column 8.15 - 8.30 - 8.45 - 9.00 - 9.15 - 10 - 10.30 - 10.45 - 11 so on till 17:00

  16. #16
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Try again:
    PHP Code: 
    Option Explicit
    Public As Double
    ' set timer
    Sub timer()
    t = WorksheetFunction.Ceiling(Minute(TimeValue(Now)), 15) '
    current minute (in whole number)round upto next 15
    ' set next run time to next hour from now, stop at 17h
    Application.OnTime Date + Hour(TimeValue(Now)) / 24 + t / 1440, "copyRng", Date + 17 / 24
    End Sub

    '
    ------------------
    Sub copyRng()
    Dim lr&, copyRng As RangepasteRng As Range
    lr 
    Cells(Rows.Count"A").End(xlUp).Row
    With WorksheetFunction
        t 
    = .Ceiling(TimeValue(Now), 15 1440'current minute round upto next 15'
        
    Set copyRng Range("A6:A" lr)
        
    On Error Resume Next
        Set pasteRng 
    Range("A6").Offset(0, .Match(tRange("C5:AM5")))
        
    Range("A6:A" lr).Copy pasteRng
        pasteRng
    .EntireColumn.AutoFit
        On Error 
    GoTo 0
    End With
    End Sub 
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Thank you very much.
    15 minutes is perfect but doesn't know, the automatic thing is not working.
    Every time have to go to code and press run to paste the next column.

    Once again thank you

  18. #18
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Hi
    Any solution please... why sheet not auto update.

  19. #19
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Hello guys,
    Mr. Bebo 021999 did a perfect timer part but unfortunately auto update not working.
    If anyone or Mr Bebo 021999 please help me out it will be great.

    Thank in advance

  20. #20
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Please upload newest file with code, to test what 'd happened

  21. #21
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Ohh hi bro thanks you,
    Same file you uploaded which am testing but nothing is happening
    Attached Files Attached Files

  22. #22
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    I am calling around for help. hope somebody reply soon.

  23. #23
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    See if this helps: https://www.myonlinetraininghub.com/...ication-ontime

    You need to set the scheduled time to a variable so that a) you can increment it and b) so you can stop the timer loop.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  24. #24
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Thank you but coding part... am very poor

  25. #25
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Thank you really appreciate your efforts

  26. #26
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    i can't post the code here (and don't know why)
    Attached Files Attached Files
    Last edited by bsalv; 08-08-2022 at 08:28 AM.
    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

  27. #27
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Stupendo fantabulous fantastically awesome.
    Thank you very very much

  28. #28
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Hi,

    Thanks again Bsalv and Bebo.
    Previously, the VBA code had to be pressed every 15 minutes to run. But now when I open the file the timer doesn't start. The timer starts only when I have to run the VBA code.

    Please check the uploaded file if the formula is added in the A column then the pasting source is changed automatically.
    Attached Files Attached Files
    Last edited by vvishalb; 08-09-2022 at 01:28 AM.

  29. #29
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    hello,
    add an "open"-event in thisworkbook

    Please Login or Register  to view this content.

  30. #30
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Bro, please check #28 post the uploaded file just added the formula in the A column the pasting results change

  31. #31
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    hello,
    Do you want to copy the data from the "Source" or from the B-column (which are the same ?)
    Attached Files Attached Files

  32. #32
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    high high high clap
    completely satisfied solution

  33. #33
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    Hello Bebo and bsalv,
    Please allow me to extend my question.
    Your code is perfect only I need 2 things to add, please.

    1) This timer keeps showing a full day which is not desired. Would it be possible to show the timer only for the time we set the timer for? and stop showing when the set timer expires. (Timing only between 8 am to 5 pm)

    2) The result data should be cleared on the next day before the new day timer starts.

  34. #34
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    hello.
    see attachment

    your point 1 = this correction
    If Hour(t) < 8 Then t = Date + TimeSerial(8, 0, 1) 'before 8 AM
    If Format(t, "hh:mm") > "17:00" Then t = Date + 1 + TimeSerial(8, 0, 1) 'after 5PM

    your point 2 = this correction
    With c(2, col + 1).Resize(20, 40) 'everything to the right of the actual column is empty with this
    .ClearContents
    .Interior.Color = xlNone
    .EntireColumn.ColumnWidth = 5
    End With
    Attached Files Attached Files

  35. #35
    Registered User
    Join Date
    08-07-2012
    Location
    India
    MS-Off Ver
    Microsoft office home and student 2016 (Windows 10 Home 64bit)
    Posts
    98

    Re: Every 1 hour data should copy paste from A to B, then A to C and so on

    I love you, boss. you are just fantastic

+ 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 range that contains data & copy and paste, if cell contains data
    By Butcher1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2020, 01:48 AM
  2. Replies: 1
    Last Post: 08-21-2020, 10:47 AM
  3. copy formula and paste for new data added and autofill.....and paste special values
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-13-2014, 07:40 AM
  4. Replies: 1
    Last Post: 04-05-2014, 11:28 AM
  5. Replies: 0
    Last Post: 04-04-2014, 09:51 AM
  6. Enter data, copy formulas, copy values, paste data, delete data
    By alf40 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-15-2013, 07:23 PM
  7. Replies: 1
    Last Post: 01-16-2013, 05:36 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