在 excel 中绘制字母

Drawing letters in excel

是否有一个插件可以帮助在 excel 中生成字母 (A-Z),如下所示?或者我们可以编写某种 VBA 脚本来执行此操作吗?

Whosebug 不是为我提供代码服务。无论如何,这个任务看起来很有趣,我决定编写一些关于它的代码:

Option Explicit

Public Sub WriteLetterA()

    Dim varLetterA(8)       As Variant
    Dim lngColCounter       As Long
    Dim lngRowCounter       As Long
    Dim blnReverse          As Boolean
    Dim rngCell             As Range

    blnReverse = True

    varLetterA(0) = Array(1, 1, 1, 0, 0, 1, 1, 1)
    varLetterA(1) = Array(1, 0, 0, 0, 0, 0, 0, 1)
    varLetterA(2) = Array(1, 0, 0, 1, 1, 0, 0, 1)
    varLetterA(3) = Array(1, 0, 0, 1, 1, 0, 0, 1)
    varLetterA(4) = Array(0, 0, 0, 1, 1, 0, 0, 0)
    varLetterA(5) = Array(0, 0, 0, 0, 0, 0, 0, 0)
    varLetterA(6) = Array(0, 0, 0, 0, 0, 0, 0, 0)
    varLetterA(7) = Array(0, 0, 1, 1, 1, 1, 0, 0)
    varLetterA(8) = Array(0, 0, 1, 1, 1, 1, 0, 0)

    Cells(1, 1).Select

    For lngRowCounter = 0 To UBound(varLetterA)
        For lngColCounter = 0 To UBound(varLetterA(lngRowCounter))
            Set rngCell = Cells(lngRowCounter + 1, lngColCounter + 1)
            If varLetterA(lngRowCounter)(lngColCounter) Then
                rngCell.Interior.Color = IIf(blnReverse, vbBlack, vbWhite)
            Else
                rngCell.Interior.Color = IIf(blnReverse, vbWhite, vbBlack)
            End If
        Next lngColCounter
    Next lngRowCounter

End Sub

'   Points for improvement  - varLetterA in a separate class
'   Refer to the sheet, do not assume it
'   Pass the first cell as a reference

这是你得到的:

blnReverse = False

blnReverse = True

查看需要改进的地方 - 如果您决定构建字母表的其余部分,它们会很有用。祝你好运。