Google Sheets隔行转置:将错位X/Y值归至同一行的函数方案
Google Sheets Solution
Option 1: Drag-and-Drop Formula
This is a simple, manual approach for applying the formula to each row:
- In cell B2, enter this formula to pull your X values (every even-positioned row from column A starting at A2):
=IFERROR(INDEX(A:A, 2*ROW()-2), "") - In cell C2, enter this formula to grab the corresponding Y values (the row immediately after each X value):
=IFERROR(INDEX(A:A, 2*ROW()-1), "") - Select both B2 and C2, then click and drag the small fill handle at the bottom-right corner down until you’ve covered all your data. The formulas will automatically adjust to pair A4→B3, A5→C3, and so on.
Option 2: Array Formula (Auto-Populate All Rows)
Skip dragging formulas entirely with array formulas that populate all rows at once:
- In cell B2, enter:
=ARRAYFORMULA(IFERROR(INDEX(A:A, SEQUENCE(ROUNDUP(COUNTA(A:A)/2), 1, 2, 2)), ""))
This creates a sequence of row numbers starting at 2, incrementing by 2 (2,4,6...) and pulls those values from column A. - In cell C2, enter:
=ARRAYFORMULA(IFERROR(INDEX(A:A, SEQUENCE(ROUNDUP(COUNTA(A:A)/2), 1, 3, 2)), ""))
This does the same but starts at 3, incrementing by 2 (3,5,7...) to capture the Y values.
Excel Solution
The logic is nearly identical in Excel, with minor tweaks based on your version:
Option 1: Drag-and-Drop Formula
- In B2:
=IFERROR(INDEX(A:A, 2*ROW()-2), "") - In C2:
=IFERROR(INDEX(A:A, 2*ROW()-1), "") - Drag the fill handle down to apply the formula to all rows.
Option 2: Dynamic Array Formula (Excel 365/2021+)
If you have Excel 365 or 2021, use dynamic arrays to auto-spill results:
- In B2:
=IFERROR(INDEX(A:A, SEQUENCE(ROUNDUP(COUNTA(A:A)/2),1,2,2)), "") - In C2:
=IFERROR(INDEX(A:A, SEQUENCE(ROUNDUP(COUNTA(A:A)/2),1,3,2)), "")
The formula will automatically spill down to cover all matching pairs.
Option 3: Legacy Excel (Pre-365)
For older Excel versions, enter the array formula using Ctrl+Shift+Enter:
- Select the range where you want X values (e.g., B2:B1000 for 1000 pairs).
- Enter
=IFERROR(INDEX(A:A, 2*ROW(B2:B1000)-2), "")and pressCtrl+Shift+Enter. - Repeat for Y values in column C with
=IFERROR(INDEX(A:A, 2*ROW(C2:C1000)-1), "").
内容的提问来源于stack exchange,提问作者GeorgeC
相关产品推荐
相关产品推荐

