After reporting truly awful results earlier this year, department stores like Macy's (NYSE:M) have started to turn the corner in the past two quarters. Sales are still falling -- but not as fast as before.

Nevertheless, one thing remains the same: Department stores are rapidly losing market share to off-price retailers. TJX Companies (NYSE:TJX) and Ross Stores (NASDAQ:ROST) both reported stellar third-quarter results last week, showing that they still have lots of room left for further growth.

Off-price retailers are rapidly gaining market share from other stores. Image source: The Motley Fool.

Sales soar again at TJX and Ross Stores

During Q3, comparable-store sales fell 2.7% year over year at Macy's, while total sales declined 4.2%. This led to a sharp contraction in Macy's profit margin. A few years ago, this kind of sales decline would have been considered a disastrous result, but it was actually better than what many analysts had feared.

While Macy's and other department stores have gotten used to sales declines in the past two years, TJX and Ross Stores haven't missed a beat. Both companies continue to post steady mid-single-digit comparable-store sales growth and high-single-digit increases in total sales.

TJX Revenue (TTM) Chart

TJX Companies vs. Ross Stores revenue. Data by YCharts.

These trends continued in Q3. At TJX, comp sales rose about 5% year over year. This drove a 7% increase in net sales, despite a roughly 2-percentage-point headwind from the strong dollar. The company saw strong results at all of its chains in the U.S. and Canada. The only weak spot was its international business, which includes stores in Europe and Australia. That segment posted flat comparable-store sales.

Ross Stores posted an even more impressive performance. Comp sales rose about 7% in Q3, while revenue jumped 10.9% year over year.

Earnings growth remains strong

Ross Stores' extremely strong revenue performance last quarter helped the company increase its profit margin significantly despite the negative impact of rising employee wages. As a result, earnings per share surged 17% year over year, to $0.62, coming in far ahead of the average analyst estimate of $0.56.

Earnings growth remains healthy at TJX, despite some big headwinds. Image source: The Motley Fool.

At TJX, adjusted EPS grew a more modest 6% year over year, reaching $0.91. That still beat the average analyst estimate of $0.87 by a comfortable margin. Gross margin rose by 0.5 percentage points relative to Q3 2016 -- roughly equivalent to the increase Ross Stores reported -- but this was more than fully offset by higher operating costs.

Big opportunities ahead

TJX and Ross Stores both projected that sales and earnings growth will slow this quarter. That said, both companies are notorious for giving very conservative guidance and then beating it by a mile. (For example, Ross Stores had forecast that comp sales would rise 1%-2% in Q3, compared to the actual result of a 7% increase.)

Both companies are also well-positioned to continue gaining market share in the coming years. Department stores and specialty apparel stores are retrenching, which will leave lots of consumer dollars up for grabs. Macy's alone plans to close 100 stores in the next year. This will likely lead to about $1 billion of lost revenue, according to Macy's management.

Not all of this revenue will go to off-price retailers. Nevertheless, when other chains' store-closure plans and modest market growth are factored in, TJX and Ross Stores should be able to sustain their strong sales trends in the U.S. for the foreseeable future.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.