Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jun 2002
    Location
    St. John, Indiana
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    excel macro (2002)

    the attached excel macro is designed to record a
    Attached Files Attached Files

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: excel macro (2002)

    If you move that code to a regular module and rename it to something else (I called it MoveToHistory), and add the last line as shown below, the code should execute every 5 seconds. You will need to run the code one time either manually, or from someplace else (like the Open Event routine) to get it started.

    <pre>Public Sub MoveToHistory()
    Set Xlsheet = Sheets("Sheet1")
    'Xlsheet.Calculate

    StockRow = 9 'This is the row of the stock price that is being updated
    StockCol = 3 'This is the column of the stock price that is being updated

    TimeRow = 9
    TimeCol = 4

    StartRow = Xlsheet.Cells(9, 10) 'This is the first row that will be populated with the stock price
    EndRow = 157 'This is the last row that will be populated with the stock price
    Col = 10 'This is column that is being populated with the stock price

    'Stop


    'Determine if the Stock Price has changed
    'This is taking the value from the stock price and putting it into the column
    If Xlsheet.Cells(StockRow, StockCol).Value = Xlsheet.Cells(StockRow + 1, StockCol) Then
    Exit Sub
    ElseIf Xlsheet.Cells(StockRow, StockCol) <> Xlsheet.Cells(StockRow + 1, StockCol) Then

    If StartRow = EndRow Then
    Exit Sub
    Else
    Xlsheet.Cells(StockRow + 1, StockCol) = Xlsheet.Cells(StockRow, StockCol)
    Xlsheet.Cells(StartRow, Col) = Xlsheet.Cells(StockRow, StockCol)
    StartRow = StartRow + 1
    Xlsheet.Cells(9, 10).Value = StartRow
    End If

    End If

    ''Next row
    'Exit Sub
    Xlsheet.Calculate
    Application.OnTime Now() + TimeValue("0:00:05"), "MoveToHistory"
    End Sub
    </pre>


    The above was not tested since I didn't have the rest of your workbook.
    Legare Coleman

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: excel macro (2002)

    It might be wise to explicitly state which workbook the macro is to process:

    Set xlSheet = Thisworkbook.worksheets("sheet1")
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  4. #4
    New Lounger
    Join Date
    Jun 2002
    Location
    St. John, Indiana
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: excel macro (2002)

    jan,

    thanks for the recommendation, and URL to the MVP website.

    regards,
    fuzzy

Posting Permissions

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