原创 Excel VBA Interior.ColorIndex 色彩列表收藏

使用如下VBA代码取得相应的单元格底色

Sub a()
    Range(
"A1").Select

    
For i = 0 To 56 Step 1
        ActiveCell.Interior.ColorIndex 
= i
        ActiveCell.Offset(
01).Value2 = i
        
If i Mod 19 = 18 And i <> 0 Then
            ActiveCell.Offset(
-182).Select
        
Else
            ActiveCell.Offset(
10).Select
        
End If
    
Next
    
End Sub

结果如下

无色 0   19   38
  1   20   39
白色 2   21   40
  3   22   41
  4   23   42
  5   24   43
  6   25   44
  7   26   45
  8   27   46
  9   28   47
  10   29   48
  11   30   49
  12   31   50
  13   32   51
  14   33   52
  15   34   53
  16   35   54
  17   36   55
  18   37   56
 

发表于 @ 2007年11月27日 14:48:00|评论(loading...)

新一篇: SAP ABAP OLE 输出数据到 Excel 无法自动保存的解决 | 旧一篇: 使用Python 3.0a1 调用外部应用程序

Csdn Blog version 3.1a
Copyright © DKman