发布网友 发布时间:2022-05-16 10:11
共1个回答
热心网友 时间:2023-10-19 08:41
执行示例:
程序代码:
程序代码文本如下(文本仅供参考,浏览器可能删除部分特殊符号和对齐空白):
Option Explicit
Sub 宏1()
Dim arr1, arr2, i&, j&
arr1 = Range("a1:c4")
ReDim arr2(1 To UBound(arr1), 1 To 1)
For i = 1 To UBound(arr1)
For j = 1 To 3
arr2(i, 1) = arr2(i, 1) & arr1(i, j)
arr1(i, j) = Len(arr1(i, j))
Next j
Next i
Range("d1:d4") = arr2
For i = 1 To UBound(arr1)
For j = 1 To Len(arr2(i, 1))
If j <= arr1(i, 1) Then
Cells(i, 4).Characters(j, 1).Font.Bold = Cells(i, 1).Characters(j, 1).Font.Bold
ElseIf j <= arr1(i, 1) + arr1(i, 2) Then
Cells(i, 4).Characters(j, 1).Font.Bold = Cells(i, 2).Characters(j - arr1(i, 1), 1).Font.Bold
Else
Cells(i, 4).Characters(j, 1).Font.Bold = Cells(i, 3).Characters(j - arr1(i, 1) - arr1(i, 2), 1).Font.Bold
End If
Next j
Next i
End Sub