Sub CFKJ1()
Dim a%, b%, c%, arr() As String
ReDim arr(1 To 9, 1 To 9)
For a = 1 To 9
For b = 1 To a
c = a * b
arr(a, b) = a & " × " & b & " = " & c
Next b
Next
With Cells(2, 2).Resize(9, 9)
.Select
.Value = arr
End With
' Cells(1, 1).Resize(9, 9) = arr
End Sub
写法二:
Sub CDKJ2()
Dim a%, b%, c%, arr() As String
ReDim arr(1 To 9, 1 To 9)
For a = 1 To 9
For b = 1 To 9
c = a * b
If a <= b Then
arr(b, a) = a & " × " & b & " = " & c
End If
Next b
Next a
With Cells(2, 2).Resize(9, 9)
.Select
.Value = arr
End With
' Cells(1, 1).Resize(9, 9) = arr
Cells(12, 3) = rds(100, 200)
End Sub