Dzwebs.Net

撰写电脑技术杂文十余年

Excel找出两列相同值的VBA宏代码

Admin | 2011-8-9 8:19:24 | 被阅次数 | 10269

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

  以下的宏代码,其功能是,找到AB两列相同值,并存放到C列。 

  Sub MySubSearch()

  Dim i As Integer
  Dim c As Range

  For i = 2 To Sheet1.[B65536].End(xlUp).Row

   For Each c In Sheet1.Range("A2:A" & Sheet1.[A65536].End(xlUp).Row)

    If Cells(i, 2).Value = c Then Cells(i, 2).Font.ColorIndex = 3
      Next c

  If Cells(i, 2).Font.ColorIndex = 3 Then _
              Cells(Sheet1.[C65536].End(xlUp).Row + 1, 3).Value = Cells(i, 2).Value
  Next i

  MsgBox  "所有重复编号已经找出,请查看结果!"
  End Sub


该杂文来自: Excel杂文

上一篇:Excel不能保存格式

下一篇:excel中的cos函数

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计