简体   繁体   English

如何在每个数据行之间将数据行从 A 列复制到 B 列

[英]How to copy a data row from column A to column B, between each data row

Troubles with the update formula Troubles with formula, asking for a missing matrix Steps, I have tried to retrieve data from column B to column D Know is telling that I insert insufficient arguments Good afternoon,更新公式的问题 公式的问题,要求缺少矩阵步骤,我试图从 B 列到 D 列检索数据知道告诉我插入不足 arguments下午好,

I have column B, with descriptions in Portuguese, row by row and column D with the translations in English: I'm trying to insert in column D the corresponding translation in Portuguese under each data row in English.我有B列,用葡萄牙语逐行描述,D列用英语翻译:我试图在D列中插入对应的葡萄牙语翻译在每个英语数据行下。

But I can't find any formula to do that, also I didn't find any question like this in the forum.但是我找不到任何公式可以做到这一点,我也没有在论坛中找到任何这样的问题。 The only nearest question about, is to insert a blank row between data rows with this formula =MOD(ROW(D2),2)=0 or with a filter adding series.唯一最近的问题是使用此公式 =MOD(ROW(D2),2)=0 或使用过滤器添加系列在数据行之间插入空白行。 And retrieving data with vlookup, as in the attached image.并使用 vlookup 检索数据,如附图所示。

Put this formula in the Result Column and adjust $A$1 to your first portuguese term and $B$1 to you first translated term:将此公式放在结果列中,并将 $A$1 调整为您的第一个葡萄牙语术语,将 $B$1 调整为您的第一个翻译术语:

'=OFFSET($A$1;((ROW()-ROW($B$1))/2)-ROW($A$1)+1;0)

You should get a Column, where every Portuguese term is repeated.您应该得到一个列,其中重复了每个葡萄牙语术语。 Now you can overwrite the formulas in the upper cells with the english translations.现在您可以用英文翻译覆盖上方单元格中的公式。

The formula calculates the difference between current (translated row) cell and the first translated row and cuts it in half: that is the row of the portuguese term to associate with this cell.该公式计算当前(翻译行)单元格与第一个翻译行之间的差异,并将其减半:即与该单元格相关联的葡萄牙语术语的行。 Then it uses that row number as offset to the first row of portuguese terms.然后它使用该行号作为第一行葡萄牙语术语的偏移量。

Now, if you want to have the forst row empty, you can of course fill the whole formula in the true part of an if formula:现在,如果您想让 forst 行为空,您当然可以将整个公式填充到if公式的true部分:

=IF(MOD(ROW()-ROW($B$1),2)=0;"";OFFSET($A$1;((ROW()-ROW($B$1))/2)-ROW($A$1)+1;0))

That is something you will often do in excel and I assume you know that trick.这是你在 excel 中经常会做的事情,我假设你知道这个技巧。 It makes the core formula a little harder to read, but it basically says: if the current row inside this block is divisible by two, then set the row empty, else set the row equal to the formula I presented above .它使核心公式更难阅读,但它基本上说:如果此块中的当前行可被 2 整除,则将该行设置为空,否则将该行设置为等于我上面介绍的公式

You can use power query to tackle this task.您可以使用电源查询来解决此任务。

I have used the following data for demonstration.我已使用以下数据进行演示。 Please note I am using Excel 365 English version .请注意我使用的是Excel 365 英文版

| Portuguese | English |
|------------|---------|
| um         | one     |
| dois       | two     |
| três       | three   |
| quatro     | four    |
| cinco      | five    |
| seis       | six     |
| Sete       | seven   |
| oito       | eight   |
| nove       | nine    |
| dez        | ten     |

Steps are:步骤是:

  1. Load/Add the data set to Power Query Editor;将数据集加载/添加到 Power Query 编辑器;
  2. Make a duplicated column of Portuguese , then add an Index column with index starting from 1 , then you should have something like below:制作一个Portuguese的重复列,然后添加一个索引从1开始的索引列,那么您应该有如下内容:

添加了重复和索引列

  1. Use Merge Columns function under Transform tab to merge the English column with the Portuguese - Copy column with a custom delimiter such as hashtag # (as long as this delimiter is not part of your original texts), then you should have:使用“ Transform选项卡下的“合并列”function 将English列与Portuguese - Copy列,例如标签# (只要此分隔符不是原始文本的一部分),那么您应该具有:

合并

  1. Use Split Columns function under Transform tab to split the merged column by the same delimiter # , and make sure in the Advanced Settings to choose to put the results into Rows as shown below:使用Transform选项卡下的Split Columns function 以相同的分隔符#拆分合并的列,并确保在 Advanced Settings 中选择将结果放入Rows ,如下所示:

分裂的

The output will look like the following: output 将如下所示:

输出

You can choose to remove the Portuguese column if you do not want to show it in the final output, then Close & Load the table to a new worksheet (by default).如果您不想在最终的 output 中显示Portuguese列,您可以选择删除它,然后关闭并将表加载到新工作表(默认情况下)。

Here are the power query M Codes behind the scene.这是幕后的电源查询M代码 All functions used are within GUI so should be easy to follow and execute.使用的所有功能都在 GUI 内,因此应该易于遵循和执行。

let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Portuguese", type text}, {"English", type text}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Portuguese", "Portuguese - Copy"),
    #"Added Index" = Table.AddIndexColumn(#"Duplicated Column", "Index", 1, 1),
    #"Merged Columns" = Table.CombineColumns(#"Added Index",{"English", "Portuguese - Copy"},Combiner.CombineTextByDelimiter("#", QuoteStyle.None),"Merged"),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Merged Columns", {{"Merged", Splitter.SplitTextByDelimiter("#", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Merged"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Merged", type text}})
in
    #"Changed Type1"

Let me know if you have any questions.如果您有任何问题,请告诉我。 Cheers:)干杯:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 转置列数据并将其复制到每一行 - Transpose and copy column data to each row 如何从工作簿A中的2个单元格复制数据并复制到单元格中的工作簿B如何启动for循环直到最后一行/列 - How to copy data from 2 cells from workbook A and copy to workbook B in a cell and how do I start a for loop until last row/column 在micosost Excel中,我如何将数据从一行中的多列复制到同一行中的一列 - In micosost excel how do i copy data from multiple columns in a row to one column in same row 如何为列中的每个唯一值创建一个新的工作簿并复制相应的行数据和模板 - How to create a new workbook for each unique value in column and copy corresponding row data plus template 用于从列到行复制和粘贴(转置)数据的宏-可伸缩 - Macro to copy and paste (transpose) data from column to row - Scalable Excel-如果第一列匹配,则从其他工作表复制行数据 - Excel - copy row data from other sheet if first column match VBA:将数据从一列复制并转置到新行 - VBA: Copy and transpose data from one column to new row Excel VBA比较列数据复制行 - Excel VBA compare column data copy row 将数据复制到最后一行和最后一列 - Copy data up to last row and column 根据A列数据将数据从不同数量的B列单元格转换为单个逗号分隔的行 - Convert data from a varying number of Column B cells to a single comma separated row based on Column A data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM