简体   繁体   English

如何将数据从列A列到列B中?

[英]How to lineup Data from Column A to Data in Column B?

Column A is inventory that I should have. A栏是我应该拥有的库存。 Column B is inventory I received. B列是我收到的清单。

I am missing a lot of inventory and have had to manually do this. 我缺少很多库存,不得不手动执行此操作。 What I want is the numbers in each column to match up & the numbers that are not present in B that are present in A to add a space in column B to show thats it's missing: 我想要的是每一列中的数字匹配以及A中存在的B中不存在的数字,以在B列中添加一个空格以表明那是缺失的:

What I have: 我有的:

在此处输入图片说明

What I want: 我想要的是:

在此处输入图片说明

This is a pretty lightweight VBA routine that will do what you need: 这是一个非常轻量级的VBA例程,可以满足您的需要:

Sub matchCells()
    Dim colARange As Range
    Dim colACell As Range

    'Change this to your Column A range size
    Set colARange = Sheet1.Range("A1:A5000") 

    'Iterate through each cell in your Column A Range
    For Each colACell In colARange.Cells

        'Check if the cell in Column A doesn't match the cell in Column B
        If Not (colACell.Value = colACell.Offset(0, 1).Value) Then

            'It doesn't match so shift Column B's cell down one
            colACell.Offset(0, 1).Insert Shift:=xlShiftDown
        End If

        'Now we loop again and we will continue shifting Column B down
        ' a cell until it matches. 

    Next
End Sub

在此处输入图片说明

You can try below formula on Column C... Should give you the result you need in Column C. 您可以在C列上尝试以下公式...应该在C列中提供所需的结果。

=IF(ISNA(VLOOKUP(A1,$B$1:$B$10,1,FALSE)),"",VLOOKUP(A1,$B$1:$B$10,1,FALSE))

$B$1:$B$10 is the Range of data (no of rows in column B) $B$1:$B$10是数据范围(B列中没有行)

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

相关问题 比较 A 列和 B 列的数据一次 - Comparing Data from Column A and Column B Once 如何在每个数据行之间将数据行从 A 列复制到 B 列 - How to copy a data row from column A to column B, between each data row 如何根据B列数据连接A列数据 - How to concatenate column A data based on column B data 将数据从B列剪切/粘贴到A列中的第一个空单元格 - Cutting/Pasting Data from column B to first empty cell in Column A Excel - 将 A 列中的数据导出到基于 B 列的文本文件中 - Excel - Export Data from Column A into a text file based on Column B 从A列(Sheet1)复制到B列先前数据下方的B列(Sheet2) - copy from column A (Sheet1) to Column B (Sheet2) below previous data of column B Excel 2003:将A列中的值与B列匹配,然后从B列中提取数据 - Excel 2003: Match value in column A with column B, then pull data from column B 如何在 A 列的循环中运行,找到一个值并从 B 列打印相应的数据 - How to run in a loop for column A , find a value and print the corresponding data from column B 使用 B 列数据将 A 列数据连接到 C 列 - Concatenate column A data into column C using column B data DAX:对C列中的数据求和,并按B列进行过滤,其中关系在A列上 - DAX: SUM a data from column C, filtering by column B where relationship is on column A
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM