我想试试,如果我在列中有值列表(" A"),这可以重复&现在我需要计算可重复的数量并在另一个工作簿中添加这些数字2在Range(" B")下显示相同的值,其值在WRKbook1的Range(" A")中通知。
这有点难以这么认为,但是尝试使用Pivot表不幸的是我并没有帮助我。
例如:工作簿1(Sheet1)给出为:
ColA: AA AA AA AB AB AB AC AC AC AC
现在我们都知道AA' s = 3,AB' s = 3,AC' s = 4现在另一个工作簿说wrkbk(2)也给出了:
ColA: AA AB AC
现在需要在wrkbk(2)上显示为:
ColA: ColB: AA 3 AB 3 AC 4
那么这是代表Colk of wrkbk(2)更新的地方吗?
谢谢大家!
答案 0 :(得分:0)
在工作簿b列b中,假设AA是单元格A1,则输入如下= COUNTIF(Sheet1!A:A,A1)
http://office.microsoft.com/en-in/excel-help/countif-HP005209029.aspx
首先将所有行从sheet1复制到sheet2并转到数据选项卡,然后点击删除重复项,然后使用上面的公式
答案 1 :(得分:0)
我修改了你的代码如下:
Sub foo()
Dim x As Workbook
Dim y As Workbook
'# Openning both workbooks first:
Set x = Workbooks.Open("C:\Users\ax1jk3\Desktop\Workbooks\Book3")
Set y = Workbooks.Open(":\Users\ax1jk3\Desktop\Workbooks\Book2")
'Navigate to the first WOrkBook
Windows("Book2").Activate
'Find all the Rown in Range A that you need to copy
Sheets("Sheet1").Range("A1:A" & Rows.Count.End(xlUp).Row).Select
Selection.Copy
'Navigate to the Other WOrkBook
Windows("Book3").Activate
Sheets("Sheet2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
'This will remove the Duplicates
ActiveSheet.Range("$A$1:$A$" & Rows.Count.End(xlUp).Row).RemoveDuplicates Columns:=1, Header:=xlNo
Range("B1").Select
ActiveCell.FormulaR1C1 = "=COUNTIF([Book12]Sheet1!C1,RC[-1])"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B" & Rows.Count.End(xlUp).Row)
Range("B1:B" & Rows.Count.End(xlUp).Row).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'Close x:
x.Close
End Sub