High/Low in a continuously updated spreadsheet

frdfrd

New Member
Joined
Apr 30, 2021
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet using the RTD function to update stock prices and option prices and I want the high/low for the day to be a field that queues off this RTD function. How can I do this. Example stock price is 10.00 then goes to 15.00 then goes to 20, then to 7.50. High for the day would be 20, low for the day 7.50 and these would be too separate fields queing of the RTD function thatis continuously updating price from a broker? Thanks
 
That is excellent, the layout of the cells couldn't be better , ideal for doing two loops. Try this code:
VBA Code:
Private Sub Worksheet_Calculate()
triggers = Range("N3:O6")
Kvalues = Range("K3:K6")
For i = 1 To 4
For j = 1 To 2
   If triggers(i, j) Then
   Application.EnableEvents = False
   Range(Cells(i + 2, 11 + j), Cells(i + 2, 11 + j)).Value = Kvalues(i, 1)
   Application.EnableEvents = True
  End If
Next j
Next i
End Sub
Note I have change the mode of addressing the output in columns L and M , this is because using " Cells(i+2),Cells(11+j) " allows me to add the two indices to constants to cover the changing rows and columns . also the reason for loading all the values in column K into a varaint array is because this is faster than doing it one cell at a time. This is important when you are dealing with realtime updates
Also when you post code can you please use the VBA fomatting which highlights the code as per my posts. you can do this by clicking on the icon which looks like a cloud with VBA under , then paste your code
Absolutely beautiful!!! Thank you so much!
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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