This year hasn't been the easiest for investors. Economic troubles have weighed on even the strongest of companies. In many cases, that's hurt their stock performance -- and the performance of our portfolios. What's the best thing we can do in this situation? Follow in the footsteps of star investor Warren Buffett.

The Oracle of Omaha, as he's sometimes called, considers bear markets an opportunity to get in on great companies at a bargain. Right now, we should remind ourselves that our portfolios won't remain in the doldrums forever. And then, like Buffett, we should continue investing. We might even follow him into a few solid names to prepare our portfolios for the new year. So, here are three Buffett stocks to buy hand over fist before 2023.

1. McKesson

McKesson (MCK -0.46%) shares have outperformed the market this year. The company distributes drugs, devices, and healthcare services. And these markets usually maintain growth no matter what the economy is doing. So, it's not surprising McKesson's earnings and share performance have defied the bear market.

But the stock clearly could climb even higher over time. McKesson not only is strong today, but it's working on a plan to boost earnings well into the future. The company is in the process of streamlining its business. It's made major progress in the divestiture of its European businesses. In just one year, it's exited 11 out of 12 countries.

At the same time, McKesson is reinforcing its presence in high-potential areas like Canada. One of the focuses there will be digital health services.

McKesson is also investing in the growth areas of oncology and biopharma services. For example, McKesson recently formed a joint venture with HCA Healthcare to improve access to oncology clinical research.

Today, McKesson shares trade for a little more than 15 times forward earnings estimates. At the same time, revenue continues to climb, and the company recently increased its fiscal 2023 adjusted earnings per share guidance. So buying shares at today's level looks like a smart move.

2. Procter & Gamble

Procter & Gamble (PG 0.65%) may suffer to a certain degree during times of higher inflation. The company sells some of the most well-known household brands -- like Bounty paper towels and Tide laundry detergent. As consumers watch their spending, they may switch to cheaper brands.

Today, the company also faces headwinds of higher costs and a stronger dollar. When the dollar strengthens, sales made abroad decline in value.

But these are short-term troubles. P&G's brand strength should keep most customers coming back over time. And so far, P&G, has managed to grow sales in spite of the economic headwinds. In the most recent quarter, organic sales rose 7% overall. And organic sales rose for all five product categories.

You'll also want to snap up shares of P&G to benefit from its dividend. The company is part of the exclusive group known as Dividend Kings. They've raised their dividends for at least 50 consecutive years. Passive income is great any time. But you'll love it even more during market downturns.

Finally, P&G trades for about 25 times trailing-12-month earnings. This is around its average level over time. Valuation doesn't fluctuate wildly. This, earnings resilience, and dividend growth are three reasons P&G is a great, safe stock to add to your portfolio now.

3. Johnson & Johnson

Johnson & Johnson (JNJ 0.22%) is another Dividend King that will ensure you passive income no matter what the market is doing. So, this is a great dividend stock to add to your holdings.

You'll also want to get in on the J&J story ahead of an upcoming transition. You probably recognize J&J as the name that brings you Band-Aid bandages and Tylenol. These are products of the company's consumer health business. But this actually is the company's smallest business in terms of revenue.

The big news is J&J is spinning off consumer health next year into a separate company called Kenvue. This leaves J&J with the higher-growth businesses of pharmaceuticals and medtech. Those units, respectively, reported 9.2% and 8.1% increases in revenue in the most recent quarter. That's compared to a less than 5% increase for consumer health.

So moving forward, we may expect strengthening earnings at J&J. The company also recently announced an acquisition of heart pump maker Abiomed. This offers J&J a solid platform in heart failure and recovery, and the deal is expected to add to earnings as of 2024.

J&J is trading at about 24 times trailing-12-month earnings, down from more than 28 early last year. That looks cheap considering the growth of J&J's core businesses so far -- and what's to come after the consumer health spinoff. That's why now is the perfect time to get in on this winning healthcare stock.