以下的宏代码,其功能是,找到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(xlU...[ 查看全文 ]
Public Sub distinctCount() '求Col列中StartRow到EndRow范围中不重复的个数 '本例是计算标题为sheet1的Excel表中的A1:A240的不重复值的个数 '修改下面四行的结尾值 Dim sheetsCaption As String: sheetsCaption = "Sheet1" Dim Col As String: Col = "A" Dim StartRow As Integer: StartRow = 1 Dim EndRow As Integer: EndRow = 240 '以下固定 Dim Count As Integer: Count = 0 With Sheets(sheets...[ 查看全文 ]