calculate Max & Min for Live market data

nt82

Board Regular
Joined
Jan 29, 2009
Messages
133
So futures market opens at 9 30 am CDT. I've a software through which i can create a DDE link and receive live market data in excel.

So Last Price ( A1 ) changes as market price moves. I would like to calculate High ( max ) and Low ( Min ) for only time period between 9 30 am to 9 45 am.

Basically I want to calculate range in that 15 mins after open.

Please let me know if anyone has a macro or formula which can acheive above task.

thanks in advance
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
You could do this with the Worksheet_Change event, like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Time >= TimeValue("09:30") And Time <= TimeValue("09:45") Then
        If Not Intersect(Target, Range("A1")) Is Nothing Then
            Range("B1").Value = Application.WorksheetFunction.Max(Range("A1"), Range("B1"))
            Range("C1").Value = Application.WorksheetFunction.Min(Range("A1"), Range("C1"))
        End If
    End If
End Sub
B1 is High, C1 is Low.
 
Upvote 0
Just tried but the code is not doing anything when i paste this code under sheet1

Any thoughts?
 
Upvote 0
If A1 is the result of a formula, use Worksheet_Calculate:
Code:
Private Sub Worksheet_Calculate()
    Application.EnableEvents = False
    If Time >= TimeValue("09:30") And Time <= TimeValue("09:45") Then
        Range("B1").Value = Application.WorksheetFunction.Max(Range("A1"), Range("B1"))
        Range("C1").Value = Application.WorksheetFunction.Min(Range("A1"), Range("C1"))
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top