I'm doing some coding for a basketball team where I have thousands of lines of data which contain 2 columns that represent X, Y coordinates where shots have been taken on a half court. I need to be able to count the number of coordinates in each area of the court. For example; calculating shots taken in the paint is easy because the paint is a rectangle area, I.e using countifs(X:X, AND(X>= 120, X<= 320), Y:Y, AND(Y<=280).
But I need to calculate shots taken from the right wing and left wing, which the coach defines as taking a straight line from underneath the basket through the top right corner of the key, and a second straight line from underneath the basket through the top left corner of the key. These lines are diagonal, and I'm having trouble figuring out how to code it correctly in VBA, since the Y coordinate value is dependent on the X coordinate value. let's say in this case, the linear equation of the line is Y=-2.48X +500, and so I need the Countif to count all the shots taken where the Y Coordinate is < 500 - (2.48 * X coordinate).
Anyone have any ideas? I'm stuck here, conceptually it would look like this but I know this doesn't work!
=countifs("Y:Y", "<500 - 2.48 * (""X:X"")")
**realize my =countifs only contains 1 criteria, using Countifs because there are other criteria I need to use as well but omitting them for ease of exercise. Other criteria I'm using include stuff like checking a column to see if the columns value = Team Name, so that it only counts rows where Team A takes a shot, or another column which indicates shot made or missed with a + or -