Excel开发学习笔记:文件选择控件、查找匹配项、单元格格式及数据有效性

时间:2025-04-27 18:05:31

一个自用的基于excel的小工具。

, ), .Cells(, ))  
        sysKpiRow.Interior.ColorIndex =  ).value = , )  
        sysKpiVal.Borders.LineStyle = Excel.XlLineStyle.xlContinuous  
        '设置单元格,添加数据有效性,下拉框选择yes和no  
        With sysKpiVal.Validation  
            .Add(Type:=Excel.XlDVType.xlValidateList, AlertStyle:=Excel.XlDVAlertStyle.xlValidAlertStop, _  
             Operator:=Excel.XlFormatConditionOperator.xlBetween, Formula1:="yes,no")  
            .IgnoreBlank = True  
            .InCellDropdown = True  
            .ShowInput = True  
            .ShowError = True  
        End With  
        sysKpiVal.Value = "yes" '统一设置默认值为yes  
    End With  
End Sub 

完整的colorIndex效果见微软网站:

https://msdn.microsoft.com/en-us/library/cc296089%28v=office.12%29.aspx#xlDiscoveringColorIndex_ColorIndexProperty