发布网友 发布时间:2022-03-02 20:23
共2个回答
热心网友 时间:2022-03-02 21:52
1.假设,有两个表格:S1和S2,里边都有数据(包括重复的),看图:热心网友 时间:2022-03-02 23:10
付费内容限时免费查看回答 1. 启动 Excel。2. 按 Alt+F11 启动 Visual Basic 编辑器。3. 在插入菜单上,单击模块。4. 在模块表中输入下面的代码:Sub Find_Matches()Dim CompareRange As Variant, x As Variant, y As Variant' Set CompareRange equal to the range to which you will' compare the selection.Set CompareRange = Range("C1:C5")' NOTE: If the compare range is located on another workbook' or worksheet, use the following syntax.' Set CompareRange = Workbooks("Book2"). _' Worksheets("Sheet2").Range("C1:C5")'' Loop through each cell in the selection and compare it to' each cell in CompareRange.For Each x In SelectionFor Each y In CompareRangeIf x = y Then x.Offset(0, 1) = xNext yNext xEnd Sub5. 按 Alt+F11 返回 Microsoft Excel。6. 输入下面的数据(保留列 B 为空):A1:1 B1:C1: 3A2:2 B2:C2: 5A3:3 B3:C3: 8A4:4 B4:C4: 2A5:5 B5:C5: 07. 选择区域 A1:A5。8. 在工具菜单上,指向宏,然后单击宏。9. 单击 Find_Matches,然后单击执行。重复的数字显示在列 B 中。您试一下