VBA 手动输入数组 - Zoidberg



我有VBA代码,可以格式化一系列单元格,在文本文件中读取,将每个单元格中的文本转换为颜色,实际上绘制了Zoidberg的图片。

我遇到的问题是文本文件...我想将文本文件的内容作为手动输入的数组包含在 VBA 中。这样我就不必有文本文件了。 这严格来说是一个内存刻录机。

文本文件与数组

是一回事(理论上(,所以我应该能够定义数组并执行与文本文件相同的所有操作......但是我错过了一些如何设置数组的东西...

 Sub Why_Not_Zoidberg()
         ' Insert Why Not Zoidberg?
         '
    'MAKE STUFF HAPPEN IN THE BACKGROUND
    Application.ScreenUpdating = False
    ActiveWindow.DisplayGridlines = False
    'DEFINE VARIABLES
    Dim Rng1 As Range

    Dim i As Long
    Dim j As Long
    Dim nName As Name
    'SET RANGE
    Set Rng1 = Range("A1:BN48")
    'CLEAR OUT ANY EXISTING JUNK
    With Rng1
        .Interior.ColorIndex = 0
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .ShrinkToFit = False
        .MergeCells = False
    End With
    ActiveSheet.Range("A1").Select

    'IMPORT TEXT FILE
    'With ActiveSheet.QueryTables.Add(Connection:= _
    '    "TEXT;C:WindowsZoidberg.txt", Destination:=Rng1 _
    '    )
    '    .Name = "Sample"
    '    .FieldNames = True
    '    .RowNumbers = False
    '    .FillAdjacentFormulas = False
    '    .PreserveFormatting = True
    '    .RefreshOnFileOpen = False
    '    .RefreshStyle = xlInsertDeleteCells
    '    .SavePassword = False
    '    .SaveData = True
    '    .AdjustColumnWidth = True
    '    .RefreshPeriod = 0
    '    .TextFilePromptOnRefresh = False
    '    .TextFilePlatform = 437
    '    .TextFileStartRow = 1
    '    .TextFileParseType = xlDelimited
    '    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    '    .TextFileConsecutiveDelimiter = False
    '    .TextFileTabDelimiter = True
    '    .TextFileSemicolonDelimiter = False
    '    .TextFileCommaDelimiter = True
    '    .TextFileSpaceDelimiter = False
    '    .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
    '    .TextFileTrailingMinusNumbers = False
    '    .Refresh BackgroundQuery:=False
    'End With
    ' ADD COLORS
    For i = 1 To Rng1.Rows.Count
      For j = 1 To Rng1.Columns.Count
        If Rng1.Cells(i, j).Value = 3 Then
            Rng1.Cells(i, j).Interior.Color = RGB(253, 3, 74)
        End If
        If Rng1.Cells(i, j).Value = -4142 Then
            Rng1.Cells(i, j).Interior.Color = RGB(255, 255, 255)
        End If
        If Rng1.Cells(i, j).Value = 1 Then
            Rng1.Cells(i, j).Interior.Color = RGB(1, 1, 1)
        End If
        If Rng1.Cells(i, j).Value = 14 Then
            Rng1.Cells(i, j).Interior.Color = RGB(0, 153, 153)
        End If
      Next j
    Next i
    'CLEAR OUT TEXT FILE STUFF
    Rng1.Select
    With Rng1
        .ClearContents
    End With
    Rng1.Select
    'SET CELL SIZE
    Selection.ColumnWidth = 2
    Selection.RowHeight = 14.25
    ActiveSheet.Range("A1").Select
    'BREAK LINK TO EXTERNAL TEXT FILE
    For Each nName In ActiveWorkbook.Names
       If Left(nName.Name, 12) <> "" Then nName.Delete
    Next nName
    Application.ScreenUpdating = True
End Sub

佐德伯格.txt

-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,1,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,3,3,3,3,3,3,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,1,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,1,1,1,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,1,3,3,1,1,1,1,1,1,-4142,-4142,1,1,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,1,3,1,1,1,-4142,-4142,1,1,1,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,1,1,-4142,1,1,-4142,-4142,1,3,3,1,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,1,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,1,-4142,-4142,-4142,-4142,1,3,3,3,3,3,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,1,1,1,1,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,1,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,1,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,1,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,1,3,3,1,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,1,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,1,3,3,3,1,3,1,3,3,1,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,1,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,1,1,1,3,3,1,3,3,1,3,3,1,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,1,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,1,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,1,1,1,3,3,1,3,3,1,3,3,1,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,1,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,1,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,1,3,3,3,1,3,1,3,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,1,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,1,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,1,3,3,3,3,3,3,3,3,3,3,3,1,3,3,1,3,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,1,-4142,-4142,1,3,3,3,3,3,3,3,1,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,1,3,3,3,3,3,3,3,3,3,3,3,1,3,1,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,1,1,1,3,3,3,3,3,3,3,3,3,3,1,3,3,3,1,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,1,14,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,1,-4142,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,1,14,14,14,14,14,14,14,14,14,14,14,1,14,14,14,14,1,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,14,14,14,14,14,14,14,14,14,14,1,14,14,14,14,1,-4142,-4142,-4142,-4142,1,1,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,14,14,14,14,14,14,14,14,14,1,14,14,14,14,1,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,14,14,14,14,14,14,14,14,14,1,1,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,-4142,-4142,-4142,1,1,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,1,1,1,1,1,1,1,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,1,-4142,1,1,3,3,3,3,3,3,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,-4142,-4142,-4142,1,3,3,3,3,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,1,1,1,1,1,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,1,-4142,1,1,1,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,1,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,1,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,1,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,1,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,1,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,1,1,1,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,1,1,1,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,3,3,3,3,3,3,3,3,3,3,3,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142,-4142

每个Excel工作表就像一个大的2D数组。根据您希望如何分发代码,我会将其存储在工作表中。我将您的 txt 文件复制并粘贴到 Excel - 选择性粘贴 - 文本中。然后我做了数据 - 文本到列,用逗号分隔。 然后我把代码改成了这个

Sub Why_Not_Zoidberg()
    Dim Rng1 As Range
    Dim i As Long, j As Long, k As Long
    Dim nName As Name
    ActiveWindow.DisplayGridlines = False
    Set Rng1 = Range("A1:BN48")
    With Rng1
        .NumberFormat = ";;;" 'hide the values in the cells
        .ColumnWidth = 2
        .RowHeight = 14.25
        .Interior.Color = RGB(255, 255, 255) 'white
    End With
    For i = 1 To Rng1.Rows.Count
      For j = 1 To Rng1.Columns.Count
        Select Case Rng1.Cells(i, j).Value
            Case 3
                Rng1.Cells(i, j).Interior.Color = RGB(253, 3, 74)
            Case -4142
                Rng1.Cells(i, j).Interior.Color = RGB(255, 255, 255)
            Case 1
                Rng1.Cells(i, j).Interior.Color = RGB(1, 1, 1)
            Case 14
                Rng1.Cells(i, j).Interior.Color = RGB(0, 153, 153)
        End Select
        For k = 1 To 100000: Next k 'adds a delay to animate
      Next j
    Next i
    Rng1.Cells(1).Select
End Sub

我会手动输入所有 ZoidDots...我的文本文件...一旦填充了单元格,然后运行我们编写的其他代码。

Sub ZoidArray()
    Dim Inx As Long
    Dim i As Long
    Dim j As Long
    Set Rng1 = Range("A1:BN48")
    Dim ZoidDots() As Variant
    
    ZoidDots = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    
    For i = 1 To Rng1.Rows.Count
      For j = 1 To Rng1.Columns.Count
        ActiveSheet.Cells(i, j).Select
            With Selection
                .Value = ZoidDots(j - 1)
            End With
            
        'For k = 1 To 1000000: Next k 'adds a delay to animate
      Next j
    Next i
End Sub

最新更新