茨の道も一歩から

インフラ構築からプログラミング(Python・JavaScript)までITに関するブログです。

66日目:Excel マクロ/VBA

Excel マクロ/VBAの講義最終日。

【講義内容】

  • 練習問題7

【ワンポイント】

VBA練習7

  • Rows.Count: 行数
  • セル.row: セルの行番号
Sub セル書式設定()
    Dim i As Integer
    Dim j As Integer
    Dim colNum As Integer
    colNum = 3
    Dim rowNum As Integer
    Dim targetStr As String
    targetStr = "〇"
    
    Worksheets("セル書式設定").Select
    For i = 1 To colNum
        rowNum = Cells(Rows.Count, i).End(xlUp).row
        For j = 1 To rowNum
            Cells(j, i).Select
            If ActiveCell.Value = targetStr Then
                ActiveCell.Interior.ColorIndex = (i * j)+3 Mod 56
            End If
        Next j
    Next i
End Sub

【今日の積み上げ】

  • Excel マクロ基本操作