zoukankan      html  css  js  c++  java
  • A macro to get all interior colorindex has been used in thisworkbook

    1集合的方法:

    Sub getallcolor()
    Dim sh As Worksheet, x As New Collection, colors(), c As Range, i As Long
    On Error Resume Next
    For Each sh In Sheets
    For Each c In sh.UsedRange
    x.Add c.Interior.ColorIndex, "key" & c.Interior.ColorIndex
    Next
    Next
    ReDim colors(1 To x.Count)
    For i = 1 To x.Count
    colors(i) = x(i)
    Next
    MsgBox "The following colorindex has been used in thisworkbook:" & vbCrLf & vbCrLf & Join(colors, vbCrLf)
    End Sub

    2字典的方法:

    Sub getallcolor()
    Dim sh As Worksheet, r As Range, mycolor As Integer
    With CreateObject("scripting.dictionary")
        For Each sh In Sheets
            For Each r In sh.UsedRange
               mycolor = r.Interior.ColorIndex
               If Not .exists(mycolor) Then .Add mycolor, Nothing
            Next
        Next
        MsgBox "The following colorindex has been used in thisworkbook:" & vbCrLf & Join(.keys, vbLf)
    End With
    End Sub 

  • 相关阅读:
    hdu 4563
    CPU中的主要的寄存器
    ROC曲线及AUC
    light oj 1231 dp 多重背包
    light oj 1422 区间dp
    light oj 1098 数学规律
    light oj 1095 组合数学
    DRAM & SRAM
    C-static
    C-枚举
  • 原文地址:https://www.cnblogs.com/fengju/p/6336324.html
Copyright © 2011-2022 走看看