Jim Cramer knows a sell-off is inevitable in the market eventually. But right now, he says stocks are rallying because of real reasons that could mean stocks are still undervalued.

"Companies keep beating the earnings estimates and raising their forecasts, rendering the current price-to-earnings multiples pretty much worthless," the "Mad Money" host said.

Cramer wasn't rationalizing reasons to buy. The simple fact is that if companies can keep delivering better earnings than expected, then maybe the market is cheaper than investors realize.

Both Home Depot and Wal-Mart delivered surprisingly strong quarters this week. The retailers' stocks appeared to be overvalued to Cramer until he heard their earnings calls. Afterwards, their valuations were more reasonable. Both gave analysts ample opportunity to raise estimates.

The same thing happened with Cisco Systems last week and Visa earlier in the month. Based on the previous quarter, Cramer was ready for downbeat numbers from Cisco. Instead, through big contract wins and positive acquisitions, Cisco went from being a potentially expensive stock to being ridiculously cheap after reporting a transformative quarter.

Visa's last quarter was a bit weaker than Cramer expected, and he thought there would be a repeat situation. Instead, Visa had acceleration in almost every venue that its business touches in the past few months. Cramer quickly realized that Visa's stock was cheap coming out of the quarter.

"It is not just earnings that is making it hard to bet against this market," Cramer said.

Activist investor Nelson Peltz's Trian Partners announced a large position in slow-growing Procter & Gamble recently, in a move that would typically lead to higher prices. Cramer found Peltz to be the one activist where if investors bought a position after he announced a new position, they could still consistently beat the market.

Likewise, Carl Icahn took a large stake in Bristol-Myers Squibb after the company had a hard time with its key anti-cancer franchise, Opdivo, which caused it to lose a tremendous amount of market cap. While many investors are betting against the stock with the notion that next quarter will be even weaker, Cramer wouldn't be surprised if Icahn could agitate management enough to prompt a bid for the company.

"Every time you want to give up on a stock, any stock, something good seems to happen," Cramer said.

Not one of these stocks has been made cheaper by President Trump's agenda, either, and Cramer doesn't expect lawmakers to take action on tax reform until late this year or early next year.

"While the stock market certainly seems expensive, individual companies can often turn out to be quite cheap given better-than-expected earnings, potential take outs or the possibility down the road of a better tax regime," Cramer said.