Because I am too idle to draw a diagram and post it - here is a word picture. (I could do it on the back of a menu in an instant....)
Graph: Origin bottom left. Vertical is FFlow, Horizontal is TAS (for a given Altitude and Weight).
Plotting useful ranges of FF/TAS you will get the classic smooth "tick" (left to right) of a combined drag curve (well nearly).
The bottom of the tick [Vimd] (or 1.05 - 1.1 of this for steep bases) is the endurance, and the tangent to the bottom of the curve is best range - nominally (classically) 1.32 Vimd (local mileages may vary). In still air this is the best range speed to fly.
But a headwind (component) will shift this graph.
Move the origin of the tangent to the right (on the TAS axis) by the amount of the local headwind. Redraw the tangent. This is now the best range speed for that headwind. Tailwinds are vv.
N.B. This assumes you have a good set of figures for the original curve. It is also constrained by VMO/MMO/Vs etc etc. But you get the idea.
Easier to see than an equation for most.
Hope this helps
MG