The next stock market correction might just be the best thing that ever happens for your stock portfolio. Corrections and crashes are inevitable in the stock market -- it's a matter of when they will happen, not if.

During the next downturn, your favorite stocks might go on sale. Don't miss the opportunity to buy great stocks at attractive prices for long-term returns. Here are three stocks that are a bit expensive at the moment, but could make great investments when a correction shakes things up.

Person excited and happy looking at their laptop on a desk.

Image source: Getty Images.

1. Microsoft

As a company, Microsoft (MSFT -1.27%) is enjoying a renaissance, and its business success has led to the stock being somewhat expensive as a result.

This 46-year-old company is the second-most-valuable publicly traded company in the world (trading places with No. 1 Apple a couple of times in 2021), and it's still delivering fantastic growth. In its most recent quarterly results, revenue was up 22% year over year. That's extremely rare, and it's only possible with a strong economic moat along with a commitment to entering new growth markets.

Microsoft has dominated the PC operating system market for decades, and its Office suite also holds nearly 90% market share. Viable competitors and alternatives exist, but Microsoft's traditional products have the brand strength, user familiarity, and overall quality to ensure that the company will be a major player in those lanes for years to come.

Microsoft used that foundation as a launchpad, repeatedly showing its willingness to wade into the next wave of growth industries. It's an established leader in the gaming market, with Xbox. Azure has nearly 20% of the cloud computing market. Outlook is a popular email client, especially for businesses, and it's built a number of customer relationship management (CRM) tools to extend its email and productivity software. Microsoft has enjoyed real success in the device business with its Surface products. Bing has a 3% global search engine market share. Even though it was eventually scrapped, Microsoft even showed initiative in the early days of the smartphone industry by developing a Windows Phone.

Microsoft is diversified as a leader in multiple tech categories, and it's shrewdly moved to the front of several high-growth industries. Azure's growth rate is above 50%, and the company's cloud segment produces more than a third of its revenue. Investors can be confident that Microsoft has incredible staying power and that it will continue to invest in new growth opportunities as they arise.

All that said, its stock is expensive. Microsoft's forward P/E ratio is around 36 now. A lot of strong performance is built into the share price, and any stumbles are likely to cause a drawdown. This is a stock to monitor. If that forward P/E ratio gets below 30 and the enterprise-value-to-EBITDA (earnings before interest, taxes, depreciation, and amortization) ratio gets down around 20, then Microsoft is a must-buy stock.

2. Veeva Systems

Veeva Systems (VEEV -0.58%) is the cloud software leader in the life sciences industry. It has more than 1,000 customers, many of whom are large pharmaceutical and biotech companies. Veeva's products support customers in drug development, data management, regulatory compliance, CRM, sales, and quality assurance.

By focusing on pharmaceutical and life sciences customers, Veeva is more valuable to customers than competitors whose products are designed for a broader range of industries. It reported 124% net subscription revenue retention last year, meaning that it not only keeps its customers but also expands its relationships with them. That competitive advantage is nearly impossible to topple in the foreseeable future, and its target customers' market is expected to grow 10%-15% annually over the next decade.

Veeva's annual sales growth rate is above 25%, but its valuation ratios are less attractive. The stock trades at a forward P/E ratio of 65 and price-to-sales ratio approaching 25. Even its strong growth outlook can't stop Veeva's PEG ratio from approaching 3, which is high. I can't wait to buy more of this stock if it gets cheaper.

3. Palo Alto Networks

Cybersecurity stocks were hot this year, and Palo Alto Networks (PANW -1.22%) was right at the front of that wave. The stock price is up around 120% since the start of 2020.

Palo Alto Networks provides a variety of enterprise security software and services. It's a major player in firewall and network security, cloud-native applications, and the up-and-coming secure access service edge (SASE), which is essential for organizations that have employees accessing their corporate software remotely. Hacks, ransomware, data theft, and a host of other issues are more prominent than ever before, and every enterprise is coming to grips with the burden of protecting themselves along with their customers.

That's driving incredible demand across the entire cybersecurity industry, and Palo Alto is one of the biggest benefactors. The company's sales rose 25% in its last fiscal year, and it followed that up with a 32% expansion in its most recent quarter. Palo Alto Networks isn't profitable on a GAAP basis, but it produces a ton of free cash flow -- equal to more than 30% of its revenue. This company has nearly unstoppable growth catalysts for the next few years, and it has the financial resources to invest in growth and acquisitions to stay competitive.

Unfortunately, those great returns in recent years have made Palo Alto Networks a tad expensive. It trades at a price-to-sales ratio above 10, and a price-to-free-cash-flow ratio close to 30. Those ratios aren't crazy in today's market, but this becomes a slam dunk if it gets just a bit cheaper.