|
- Sub Main()
- Range("C3:x21").Interior.Color = xlNone
- Range("B2:x21").Font.Color = 0
- For i = 1 To 20
- For j = 1 To 20
- If i >= j Then
- Cells(i + 1, j + 1).Value = i * j
- Else
- Cells(i + 1, j + 1).Value = IIf(i = 1, j, i)
- If i > 1 Then Cells(i + 1, j + 1).Font.Color = RGB(182, 182, 182)
- End If
- If i > 1 And i = j Then Cells(i + 1, j + 1).Font.Color = vbRed
- Next
- Next
- Cells(1 + 1, 23).Value = "平方数"
- Cells(1 + 1, 24).Value = "立方数"
- For i = 2 To 20
- Cells(i + 1, 23).Value = i * i
- Cells(i + 1, 24).Value = i * i * i
- Next
- End Sub
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Range("B2:x21").Interior.Color = xlNone
- If Intersect(Target(1), Range("c3:u21")) Is Nothing Then Exit Sub
- If Target(1).Row < Target(1).Column Then Exit Sub
- Cells(Target(1).Row, 2).Resize(1, Target(1).Row - 1).Interior.Color = vbYellow
- Range(Target(1), Cells(2, Target(1).Column)).Interior.Color = vbYellow
- End Sub
复制代码
|
|