In July 1864, the XIX Corps, of which the 38th Massachusetts was a part, was transferred to the Shenandoah Valley in Virginia and were attached to the Army of the Shenandoah commanded by Maj. Gen. Philip Sheridan. The 38th Massachusetts was engaged in several battles of the Valley Campaigns of 1864, mostly notably the Third Battle of Winchester on September 19, 1864 and the Battle of Cedar Creek on October 19, 1864 where they suffered significant casualties.