从另一个工作表的列表中查找文本或数字,并突出显示每个实例

时间:2016-07-18 06:45:57

标签: vba excel-vba excel

我有2张超过50K数据点的表(表1),以及一个数字和字母数字超过30K的表(表2,A列)。我想要一个宏代码从工作表1中的工作表2中搜索每个单元格,并更改每个实例的背景颜色。 例: 搜索:ABC123 ,应找到" Stack_Overflow Abc123 " ## @@"。

等单元格

我找到了一些代码,但到目前为止,他们并不满足我的要求:

_animateCircle: function (element, delayInterval) {
            var radius = element.getAttribute("r");
            var scaleVal;
            var $ele = $(element);
            var layer = this;
            $ele.delay(delayInterval).each(function () { }).animate(
                {   
                    r: radius // if i comment this line, exception not occur. But animation not working
                },
                {
                    duration: 700,

                    step: function (now) {
                        scaleVal = now;
                    }
                }
            );
        }

我是VBA的新手,所以详细的解释将是最有帮助的

1 个答案:

答案 0 :(得分:0)

试试这个:

Sub HighlightListed()
        Dim searches As New Collection
        Dim search As Variant
        Dim cell As Range
        For Each cell In Sheets("List").Range("A1:A30")
            If cell.Value <> "" Then
                searches.Add cell.Value
            End If
        Next cell
        For Each cell In Intersect(Sheets("Data").Range("A:A"), Sheets("Data").UsedRange)
            For Each search In searches
                If InStr(0, cell.Value, Cstr(search), 1) > 0 Then
                    cell.Interior.Color = RGB(255, 0, 0)
                    Exit For
                End If
            Next search
        Next cell
End Sub