0

バンカー インデックスとバンカー名としての列を含む 2 列のテーブルがあります。VBA を使用してバンカーにインデックスを付けてから、列をバンカー名として、「最初の列を日付として」別のテーブルを生成する必要があります。バンカーの数を変更する場合(10 から 8 のように) 2 番目のテーブルのセルの色 (以前に入力された最後の 2 列) は同じ (青) のままで、デフォルト (白) として必要です

ワークブックから多くの変数を使用しました。この点に関する任意の提案。フォーマットはどのように行うべきですか?

これはコードです:

Sub Bunker_index_Click()
    Sheet3.Range(Sheet3.Cells(4, 6), Sheet3.Cells(500, 100)).ClearContents

    Dim N As Integer
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim LocalIYM As Date
    LocalIYM = ThisWorkbook.IYM
    N = Application.CountA(Range("B:B")) - 1
    ThisWorkbook.NumBunker = N
    MsgBox (N)
    Cells(5, 1).Value = "Bunker Index"

    For i = 1 To 100
        If i <= N Then
            Cells(5 + i, 1).Value = i
            Cells(5 + i, 1).Interior.Color = RGB(253, 233, 217)
            Cells(5 + i, 2).Interior.Color = RGB(219, 238, 243)
        Else
            Cells(5 + i, 1).ClearContents
            Cells(5 + i, 2).ClearContents

        End If

    Next i

        Range("F5").Value = "Time (LOCKED)"
        Range("F5").Interior.Color = RGB(253, 233, 217)
        For i = 1 To 100
            If i <= N Then
                Cells(5, 6 + i).Value = Cells(5 + i, 2)
                Cells(5, 6 + i).Interior.Color = RGB(253, 233, 217)
            Else
                Cells(5, 6 + i).ClearContents         ' unable to bring back th original
                                                      ' color of the cells

            End If

        Next i

    For k = 1 To 12 * 1
        If k <= ThisWorkbook.N Then
             Cells(k + 5, 6).Value = LocalIYM
             LocalIYM = DateAdd("m", 1, LocalIYM)
             Cells(5 + k, 6).Interior.Color = RGB(253, 233, 217)            ' problem handling borders
           '  Range("B2").Borders(xlEdgeLeft).LineStyle = XlLineStyle.xlDashDot

         '    1edgeleft).LineStyle = x1linestyle.x1countinous

             For j = 1 To N
                Cells(5 + k, 6 + j).Interior.Color = RGB(219, 238, 243)
             Next j

        Else
             Sheet2.Cells(i + 4, 6).Clear
        End If
    Next k
End Sub
4

1 に答える 1

0

代わりに、.clearまたは.clearcontents試してください:

.Interior.Pattern = xlNone
于 2012-07-05T09:59:35.620 に答える