+ Reply to Thread
Results 1 to 11 of 11

using a timer to automate a macro

Hybrid View

vwm1 using a timer to automate a... 11-30-2009, 10:26 AM
Jack in the UK Re: using a timer to automate... 11-30-2009, 10:30 AM
vwm1 Re: using a timer to automate... 11-30-2009, 10:36 AM
Jack in the UK Re: using a timer to automate... 11-30-2009, 10:40 AM
Jack in the UK Re: using a timer to automate... 11-30-2009, 10:42 AM
vwm1 Re: using a timer to automate... 11-30-2009, 10:43 AM
Andy Pope Re: using a timer to automate... 11-30-2009, 10:44 AM
  1. #1
    Registered User
    Join Date
    11-30-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    8

    using a timer to automate a macro

    Hi,

    I cant figure out how to get the data to be pasted in the cell below on each new event of the timer. below is teh code i'm using

    Sub ButtonCode()
         Dim rows As Integer
         ' execute macros
        rows = rows + 1
        RefreshData
        
    
        Sheets("FTSE 100").Select
        Range("B10:J10").Select (copied data will always have the same location)
        Selection.Copy
        Sheets("sheet2").Select
        Range("B" & rows).Select (want to increase the row number by one for each new set of data)   
     Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=False
        Range("G18").Select
        
       
         ' submit macro to run again in 5 min
        Application.OnTime Now + TimeValue("00:01:00"), "ButtonCode"
    rows = rows
    
    End Sub
    The code updates as it should but overwrites the same cells each time.

    Any help much appreciated
    Last edited by vwm1; 11-30-2009 at 10:36 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: using a timer to automate a macro

    I think your need to sort your post out see rule 3 i think it is

    I can not reply until you have

    jiuk

  3. #3
    Registered User
    Join Date
    11-30-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: using a timer to automate a macro

    opps sorry corrected now

  4. #4
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: using a timer to automate a macro

    What is

    RefreshData

  5. #5
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: using a timer to automate a macro

    this is the past code you have
    Selection.PasteSpecial
    As you saying each time you run the code you want the paste to be G18 then G19 G20 etc ?

  6. #6
    Registered User
    Join Date
    11-30-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: using a timer to automate a macro

    sorry it is a subroutine. please see attached for full code.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-30-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: using a timer to automate a macro

    yup exactly that each time it goes over the top, i tried looping it but think i got it wrong.... as just repeated same line over again rather than in time increments

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: using a timer to automate a macro

    The rows variable will be zero'd every time the routine runs.

    Use code to get next empty row.

    rows = activesheet.cells(activesheet.rows.count,1).end(xlup).row+1
    Last edited by Andy Pope; 11-30-2009 at 10:53 AM.
    Cheers
    Andy
    www.andypope.info

+ Reply to 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