1

我有一个 30K+ 行的 excel 表(原始),有一个 Header 行,后跟一个值行,整个 excel 表行是这样交替的。

我需要将一行中所有唯一标题的列表复制到新工作表(所需),以及相应标题下方的所有相关值。

简而言之,我正在尝试将“原始”表合并到“所需”中。

非常感谢您对此的任何帮助。

这是我的示例原始表:

Header1  Header6  Header5  Header3  Header4  Header2
1        223      3        4        5        6
Header4  Header3  Header2  Header6  Header5  Header1  Header7
12       53       879      234      546      123      876
Header2  Header3  Header5  Header6  Header4  Header1
abc      sdf      weroit   scfm     Aasd     ertmn
Header5  Header3  Header8  Header6  Header2  Header1  Header7  Header4
123      sdf      564      sdg      nhd      234      vdsq     234

这是我想要的表:

Header1  Header2  Header3  Header4  Header5  Header6  Header7  Header8
1        6        4        5        3        223
123      879      53       12       546      234      876
ertmn    abc      sdf      Aasd     weroit   scfm
234      nhd      sdf      234      123      sdg      vdsq     564

谢谢-拉克什

4

1 回答 1

0

Thank you for (a) providing a data sample (even space delimited!) and (b) the desired result (even consistent with the data sample!)

Using formulae, one option possibility is as below:

  • Work on a copy of your spreadsheet.
  • Clone your entire array alongside the existing one (I’d guess into I1:P30000).
  • Delete (shift up) the first row of the ‘clone’.
  • Filter ColumnI based on ‘Contains: Header’ and delete entire rows.
  • Cut and insert I alongside A .. to .. O (alongside what should be M).
  • Copy ‘Header1’ into Q1 and drag to the right until ‘Header8’.
  • Insert the formula below in Q2 and copy across/down as required:

    =IFERROR(INDEX($A2:$P2,1,MATCH(R$1,$A2:$P2,0)+1),"")

  • Select entire sheet contents and Copy > Paste Special > Values.

  • Delete A:Q, Left align and Save as “Desired”.

This seems quite viable for occasional use, though obviously VBA wins hands down if required often. So maybe turn on macro recorder while taking the above steps?

于 2013-03-07T20:28:53.007 回答