求助:用Excel公式提取字符串中第二个"左侧1-5位的测量值
Got it, let's solve this problem of grabbing that second measurement value right before the second double quote. Your current formula works great for the first one, so let's build on that logic with a few tweaks tailored to your string structure.
The Reliable Formula for Your String Structure
Since your examples follow the pattern [Measurement1]"BW x [Measurement2]"BW, we can leverage the "x " separator to pinpoint the second measurement easily. Here's the formula:
=TRIM(MID(D48,FIND("x",D48)+1,FIND(CHAR(34),D48,FIND("x",D48))-FIND("x",D48)-1))
Breakdown of How It Works
Let's walk through each part so you understand what's happening:
FIND("x", D48): Locates the position of the "x" that separates the two measurements.FIND("x", D48)+1: Moves past the "x" to the start of the space/characters leading to the second measurement.FIND(CHAR(34), D48, FIND("x", D48)): Finds the second double quote (starting the search after the "x" to avoid the first quote).MID(...): Extracts the substring between the end of the "x" and the second double quote.TRIM(): Cleans up any extra spaces that might be around the measurement value.
Testing with Your Examples
- For
2"BW x 1"BW, the formula returns1 - For
2-1/2"BW x 1-1/2"BW, it returns1-1/2
If You Need to Handle Edge Cases
If there's ever variation in the separator (like multiple spaces around "x"), this formula still works because TRIM() takes care of extra whitespace. If your string structure changes slightly, just adjust the FIND("x", D48) part to match the new separator.
内容的提问来源于stack exchange,提问作者Richard G

