|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub Fish()
- Dim i&, k&, alen As Byte, b As Boolean, qtstr$, atstr$, n&
- Application.ScreenUpdating = False
- With Sheet1
- .Range("c2:c" & .Rows.Count).Clear
- For i = 1 To .Range("b" & .Rows.Count).End(xlUp).Row
- If .Cells(i, 2).Value Like "第*部分" Then
- n = n + 1
- .Cells(i, 2).Copy .Cells(n, 3)
- ElseIf Left(.Cells(i, 2), 1) <> "答" Then
- b = False: qtstr = "": atstr = ""
- For k = 1 To Len(.Cells(i, 2))
- If .Cells(i, 2).Characters(k, 1).Font.Underline = xlUnderlineStyleSingle Then
- If b Then
- qtstr = qtstr & " "
- atstr = atstr & Mid(.Cells(i, 2), k, 1)
- Else
- qtstr = qtstr & "("
- atstr = atstr & "|" & Mid(.Cells(i, 2), k, 1)
- b = True
- End If
- Else
- If b Then
- qtstr = qtstr & ")" & Mid(.Cells(i, 2), k, 1)
- b = False
- Else
- qtstr = qtstr & Mid(.Cells(i, 2), k, 1)
- End If
- End If
- Next
- atstr = "答案:" & Mid(atstr, 2)
- .Cells(n + 1, 3) = qtstr
- .Cells(n + 2, 3) = atstr
- .Cells(n + 2, 3).Font.Color = 255
- .Cells(n + 1, 3).Resize(2, 1).Font.Size = 12
- n = n + 2
- End If
- Next
- .[c:c].VerticalAlignment = xlCenter
- .[c:c].Font.Name = "仿宋"
- .[c:c].WrapText = True
- End With
- Application.ScreenUpdating = True
- MsgBox "修改完成!", vbInformation, "提示信息"
- End Sub
复制代码 |
|