I have looked around and could not locate the formula I need for my automated stock program. I know it is possible.. I am not sure as to how I can go about it...
The Yahoo Stock Quote History data has the:
"DATE" (01/01/16) in column "A",
"Opening" price is in column "B",
"Closing" price is in column "E".
I also have a YEAR in Column "H" using the formula =IF(B2="","",YEAR($A2))
Since the first trading day of the year is not on January 1, I need to find the "Opening" price of the first trading day of a specified year and the "Closing" price of the last trading day of that year. The year that is used for the search is located in the fields below. The Yahoo Stock Quote History downloaded data is for (current date data is located in A2):
Current year = Year to Date (2016) - Year located in AF40 as 2016
Current year - 1 (2015) - Year located in AF39 as 2015
Current year - 2 (2014) - Year located in AF38 as 2014
Current year - 3 (2013) - Year located in AF37 as 2013
Current year - 4 (2012) - Year located in AF36 as 2012
Current year - 5 (2011) - Year located in AF35 as 2011
The output would fill:
2016 (AG40), Open Price (AH40), Close Price (AI40)
2015 (AG39), Open Price (AH39), Close Price (AI39)
..
..
..
2011 (AG35, Open Price (AH35), Close Price (AI35)
I was thinking of finding the last row with data in column "A", stepping through each row from the bottom up and when the year matched use that row as the first trading day, get the data, save the data in the designated cells and once that was achieved, continue stepping upward until the next year matched, back up a row and get the closing price from the previous year... restart stepping upward and continue until the 1st record is reached (most current stock price information) ???
The other way I was thinking of doing it was to use the "YEAR" in Column "H" and step upward using that field with pretty much the same logic as above???
Any thoughts... EASIER way?
Don
The Yahoo Stock Quote History data has the:
"DATE" (01/01/16) in column "A",
"Opening" price is in column "B",
"Closing" price is in column "E".
I also have a YEAR in Column "H" using the formula =IF(B2="","",YEAR($A2))
Since the first trading day of the year is not on January 1, I need to find the "Opening" price of the first trading day of a specified year and the "Closing" price of the last trading day of that year. The year that is used for the search is located in the fields below. The Yahoo Stock Quote History downloaded data is for (current date data is located in A2):
Current year = Year to Date (2016) - Year located in AF40 as 2016
Current year - 1 (2015) - Year located in AF39 as 2015
Current year - 2 (2014) - Year located in AF38 as 2014
Current year - 3 (2013) - Year located in AF37 as 2013
Current year - 4 (2012) - Year located in AF36 as 2012
Current year - 5 (2011) - Year located in AF35 as 2011
The output would fill:
2016 (AG40), Open Price (AH40), Close Price (AI40)
2015 (AG39), Open Price (AH39), Close Price (AI39)
..
..
..
2011 (AG35, Open Price (AH35), Close Price (AI35)
I was thinking of finding the last row with data in column "A", stepping through each row from the bottom up and when the year matched use that row as the first trading day, get the data, save the data in the designated cells and once that was achieved, continue stepping upward until the next year matched, back up a row and get the closing price from the previous year... restart stepping upward and continue until the 1st record is reached (most current stock price information) ???
The other way I was thinking of doing it was to use the "YEAR" in Column "H" and step upward using that field with pretty much the same logic as above???
Any thoughts... EASIER way?
Don