首页 > 解决方案 > 单元格的vba颜色

问题描述

我需要有关 vba 的帮助如何将单元格(1,1)着色为红色

标签: excelvba

解决方案


Option Explicit

    Sub Test()

        'In "with statement" we include the name of workbook & the name of worksheet we want to execute the code.
        With ThisWorkbook.Worksheets("Sheet1")

            'Using cell referencing
            .Cells(1, 1).Interior.Color = vbRed

            'Using range referencing
            .Range("A1").Interior.Color = vbRed

        End With

    End Sub

推荐阅读