[英]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.