Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 颜色代码使用交替颜色在excel的字段中复制条目_Mysql_Vba_Excel_Duplicates - Fatal编程技术网

Mysql 颜色代码使用交替颜色在excel的字段中复制条目

Mysql 颜色代码使用交替颜色在excel的字段中复制条目,mysql,vba,excel,duplicates,Mysql,Vba,Excel,Duplicates,我已将MySQL数据库中的重复列表提取到excel工作表中。此excel显示,基于excel工作表的单个字段,我们有重复(~1900)的条目,有时有三个 例如: 10019 10019 10048 10048 10060 10060 我怎样才能对重复的对进行着色,以便它们可以很容易地可视化为每一对的一对。基本上,我想用交替的颜色填充每一对复制品,这样我就可以很容易地看到这些复制品。您所说的过程称为“复制带”。一对物体应该能很容易地解决这个问题 Sub colorDuplicateColor2(

我已将MySQL数据库中的重复列表提取到excel工作表中。此excel显示,基于excel工作表的单个字段,我们有重复(~1900)的条目,有时有三个

例如:

10019
10019
10048
10048
10060
10060

我怎样才能对重复的对进行着色,以便它们可以很容易地可视化为每一对的一对。基本上,我想用交替的颜色填充每一对复制品,这样我就可以很容易地看到这些复制品。

您所说的过程称为“复制带”。一对物体应该能很容易地解决这个问题

Sub colorDuplicateColor2()
    Dim d As Long, dODDs As Object, dEVNs As Object, vTMPs As Variant
    Dim bOE As Boolean
    
    Set dODDs = CreateObject("Scripting.Dictionary")
    Set dEVNs = CreateObject("Scripting.Dictionary")
    dODDs.CompareMode = vbTextCompare
    dEVNs.CompareMode = vbTextCompare
    
    With Worksheets("Sheet7")
        If .AutoFilterMode Then .AutoFilterMode = False
        
        With .Range(.Cells(1, "C"), .Cells(Rows.Count, "C").End(xlUp))
            
            With .Columns(1)
                .Cells.Interior.Pattern = xlNone
            End With
            
            With .Resize(.Rows.Count - 1, 1).Offset(1, 0)
                vTMPs = .Value2
            End With
            
            For d = LBound(vTMPs, 1) To UBound(vTMPs, 1)
                'the dictionary Items have to be strings to be used as filter criteria
                If Not (dODDs.exists(vTMPs(d, 1)) Or dEVNs.exists(vTMPs(d, 1))) Then
                    If bOE Then
                        dODDs.Item(vTMPs(d, 1)) = CStr(vTMPs(d, 1))
                    Else
                        dEVNs.Item(vTMPs(d, 1)) = CStr(vTMPs(d, 1))
                    End If
                    bOE = Not bOE
                End If
            Next d
            
            With .Columns(1)
                .AutoFilter Field:=1, Criteria1:=dODDs.Items, Operator:=xlFilterValues
                .SpecialCells(xlCellTypeVisible).Interior.Color = RGB(210, 210, 210)
                'use this to band the entire row
                '.SpecialCells(xlCellTypeVisible).EntireRow.Interior.Color = RGB(210, 210, 210)
                'use this to band the row within the UsedRange
                'Intersect(.Parent.UsedRange, .SpecialCells(xlCellTypeVisible).EntireRow).Interior.Color = RGB(210, 210, 210)
                .AutoFilter
                .AutoFilter Field:=1, Criteria1:=dEVNs.Items, Operator:=xlFilterValues
                .SpecialCells(xlCellTypeVisible).Interior.Color = RGB(255, 200, 200)
                .Cells(1).EntireRow.Interior.Pattern = xlNone
            End With
            
        End With
        
        If .AutoFilterMode Then .AutoFilterMode = False
    End With
    
    dODDs.RemoveAll: Set dODDs = Nothing
    dEVNs.RemoveAll: Set dEVNs = Nothing
    Erase vTMPs

End Sub
当然,数据必须按重复条件列进行排序


这个过程可以很容易地调整为整行或数据块带内的行。

类似的问题和答案在这里,有一个很好的组合,它将形成一个很好的条件格式规则,但1900行对于循环处理来说太多了。计算延迟以分钟为单位,而不是以秒为单位。我建议使用VBA或helper列。对成对进行颜色编码非常有效,我如何使其突出显示整行而不是单个单元格。我曾认为这可能会增强该过程。您是指整行(A:XFD)还是数据块的范围(可能是跨行1的列标题标签的限制)?我提供了两种选择,但不幸的是,我现在无法对它们进行测试。最好将行的颜色设置为列标题的宽度。Work的@Jeeped很棒,除了它还突出显示了电子表格标题。