Hello Rynofasho,
Since the data appears to be imported by a web query, the Worksheet_Change() event will not fire when the cells are updated. A different method would need to be used to call the macro. To do that would require your original workbook.
In the meantime, here is a VBA macro that fill in column "G" based on the high and low session values, sum all the entries in the "Trade" data, and the output those sums next to the corresponding value in column "H". This has been added to the attached workbook and can be run by clicking the button on the worksheet.
Sub VolumeAtPriceBreakdown()
Dim DSO As Object
Dim Key As Variant
Dim Keys As String
Dim Item As Variant
Dim HiLoRng As Range
Dim N As Long
Dim SessionHigh As Double
Dim SessionLow As Double
Dim TradeRng As Range
Dim Wks As Worksheet
'Worksheet with the imported data
Set Wks = Worksheets("Sheet1")
'Subtract the high and low session values
SessionHigh = Wks.Range("G3")
SessionLow = Wks.Range("G2")
'Count the number of values
N = (SessionHigh - SessionLow) * 10000
'Define the range that will hold the session values
Set HiLoRng = Wks.Range("G6").Resize(N + 1, 1)
'Create an associative array
Set DSO = CreateObject("Scripting.Dictionary")
'Fill in the values by .0001 increments and load the associative array
For I = 0 To N
Key = SessionLow + (I / 10000)
HiLoRng.Cells(I + 1, 1) = Key
If Not DSO.Exists(SessionLow + (I / 10000)) Then DSO.Add CStr(Key), 0
Next I
'Get the data in columns B6:Cx - where x is the last cell with data
Set TradeRng = Wks.Range("A1").CurrentRegion.Offset(5, 1)
Set TradeRng = TradeRng.Resize(TradeRng.Rows.Count - 5, 2)
'Sum all the entires using the associative array
For I = 1 To TradeRng.Rows.Count
Key = CStr(TradeRng.Cells(I, 1))
Item = TradeRng.Cells(I, 2).Value
If DSO.Exists(Key) Then DSO(Key) = DSO(Key) + Item
Next I
'Set the output range to all zeroes
HiLoRng.Offset(0, 1).Value = 0
'Copy the sums from the associative array to the output range
HiLoRng.Offset(0, 1).Value = WorksheetFunction.Transpose(DSO.Items)
End Sub
Bookmarks