We're nearing the end of the quarter and that could explain a lot of the volatility we're seeing in the stock market, Jim Cramer told his Mad Money viewers Tuesday. How should investors play this seesaw market? Cramer offered up some advice.

The first reason for this week's selloff was Apple (AAPL) , an Action Alerts PLUS holding. Cramer explained that tepid sales of Apple's new iPhone 8 may just be confusion over the unreleased iPhone X, but that won't stop investors from selling Apple and all of its suppliers needlessly.

So many people that try to trade Apple end up buying high and selling low, which is why Cramer continued to recommend just owning Apple for the long term. The company is trading at just 14 times 2018 estimates and has $260 billion in cash.

The second selloff fear is in the cloud, Cramer said, with investors taking a cue from one line in the Adobe Systems (ADBE) conference call about slowing sales. This news sent all of the cloud stocks lower, but Cramer said he's still a fan of everything cloud-related.

The fact is that it's the end of the quarter and it's only natural for some investors to take profits. It's also the time when hedge funds see redemptions and need to sell to cover them. What's more important, however, is that investors use this weakness for what it is -- a buying opportunity.

Over on Real Money, Cramer explains why he is dismissive of the cloud-growth narrative. Get his insights with a free trial subscription to Real Money.

Executive Decision: Red Hat

For his "Executive Decision" segment, Cramer sat down with Eric Shander, CEO of open-source software provider Red Hat Inc.  (RHT) , which just posted a 10-cents-a-share earnings beat with bullish guidance -- news that sent shares up 4% on the day.

Shander painted a very bullish picture for Red Hat, saying the strength this quarter was across the board and not limited to just one sector or geography. The investments Red Hat has made in its platform are paying off, he noted, and that can be seen in its strong growth.

When asked for more details on the business, Shander added that sales to the federal government remain strong and have not been capped as some had feared. He also called out Europe as a growing market for his company.

The discussions with companies regarding the cloud are changing, Shander said. Initially, moving to the cloud was all about saving money. But today, companies like Key Corp (KEY) are looking to speed development by containerizing applications into manageable pieces. Red Hat has all of the components these companies need for a successful deployment, Shander said.

Executive Decision: VMWare

In his second "Executive Decision" segment, Cramer sat down with Sanjay Poonen, COO of Customer Operations at VMWare (VMW) , the cloud software company that's fallen $4 from its recent highs.

Poonen said that VMWare remains the de facto name in data centers and has saved enough energy to power 40% of the homes in the U.S. for an entire year. VMWare has also recently partnered with Amazon.com's (AMZN) AWS to bring scaleable solutions to public and private clouds, and now makes it easy to scale data center capacity on the fly.

Poonen called out Nike (NKE) as a great example of what VMWare can do. He explained that Nike not only uses his company's virtualization, data center and cloud software, but also its mobile security services as well.

Lightning Round

In the Lightning Round, Cramer was bullish on Southwest Airlines (LUV) , Delta Air Lines (DAL) , General Electric (GE) and Portola Pharmaceuticals (PTLA) .

Cramer was bearish on Spirit Airlines (SAVE) .

Off the Charts: Eli Lilly

In the "Off The Charts" segment, Cramer checked in with colleague Tim Collins over the chart of Eli Lilly (LLY) .

Collins first looked at a daily chart of Lilly, noting a seesaw pattern, with highs near $84 in July, lows of $77 in August and shares now back to $84. With each decline, the stock had a strong floor of support with a rapid recovery on strong volume.

The weekly chart was also bullish in Collins' view, with a ceiling of $84.25 that was recently breached. Cramer agreed, seeing a bullish "W" pattern that he called one of the most reliable in the book.

To look at the charts and read more of Collins's analysis, see the full story here.

Cramer and the AAP team say it takes discipline to get stock prices right. Find out what they're telling their investment club members about Illinois Tool Works (ITW) , Broadcom Ltd. (AVGO) and Apple, and get in on the conversation with a free trial subscription to Action Alerts PLUS.

Search Jim Cramer's "Mad Money" trading recommendations using our exclusive "Mad Money" Stock Screener.

To watch replays of Cramer's video segments, visit the Mad Money page on CNBC.

To sign up for Jim Cramer's free Booyah! newsletter with all of his latest articles and videos please click here.

More of What's Trending on TheStreet:

At the time of publication, Cramer's Action Alerts PLUS had a position in ITW, AVGO, AAPL, KEY, LUV, GE, LLY.

More from Jim Cramer

Okta, Celgene, Altria: 'Mad Money' Lightning Round

Okta, Celgene, Altria: 'Mad Money' Lightning Round

Tread Carefully: Cramer's 'Mad Money' Recap (Friday 6/15/18)

Tread Carefully: Cramer's 'Mad Money' Recap (Friday 6/15/18)

Cramer Answers: Does Owning the FAANG Stocks Make You Diversified?

Cramer Answers: Does Owning the FAANG Stocks Make You Diversified?

Don't Rob Peter to Pay Paul When It Comes to Tech Stocks, Cramer Explains

Don't Rob Peter to Pay Paul When It Comes to Tech Stocks, Cramer Explains

This Newly Public Trucking Company Expects Rising Freight Costs to Continue

This Newly Public Trucking Company Expects Rising Freight Costs to Continue