|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
* 楼主,请勾选文字后,执行宏;第二次勾选文字后,按热键 F3 即可!
- Sub aaaa_zzpsx()
- KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF3), KeyCategory:=wdKeyCategoryMacro, Command:="aaaa_zzpsx"
- Dim r As Range, i As Paragraph, c As Cell, n As Long
- With Selection
- If .Type = 1 Then MsgBox "No-Select!", 0 + 16: End
- If .Text Like vbCr & "*" Then .MoveStart
- If .Text Like "*" & vbCr & vbCr Then .MoveEnd 1, -1
- Set r = .Range
- .InsertAfter Text:=vbCr & .Text
- For Each i In r.Paragraphs
- If i.Range Like "*#?" Then i.Range.Characters.Last.Previous.Delete
- Next
- Do
- .MoveStart 4
- Loop Until .Text Like vbCr & "*"
- .MoveStart 4
- .ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=1, AutoFitBehavior:=wdAutoFitFixed
- .InsertColumnsRight
- For Each c In .Cells
- n = n + 1
- c.Range.Text = .Tables(1).Columns(1).Cells(n).Range.Characters.Last.Previous.Text
- Next
- .Sort ExcludeHeader:=False, FieldNumber:="列 2", SortFieldType:= _
- wdSortFieldNumeric, SortOrder:=wdSortOrderAscending, FieldNumber2:="", _
- SortFieldType2:=wdSortFieldSyllable, SortOrder2:=wdSortOrderAscending, _
- FieldNumber3:="", SortFieldType3:=wdSortFieldSyllable, SortOrder3:= _
- wdSortOrderAscending, Separator:=wdSortSeparateByCommas, SortColumn:= _
- False, CaseSensitive:=False, LanguageID:=wdSimplifiedChinese, _
- SubFieldNumber:="段落数", SubFieldNumber2:="段落数", SubFieldNumber3:="段落数"
- .Tables(1).Columns(1).Select
- .InsertColumns
- n = 0
- For Each c In .Cells
- n = n + 1
- c.Range.Text = .Tables(1).Columns(2).Cells(n).Range.Characters.First.Text
- Next
- .Tables(1).Columns(2).Delete
- .Tables(1).Columns(2).Delete
- .Rows.ConvertToText Separator:=wdSeparateByDefaultListSeparator, NestedTables:=True
- .Text = Replace(.Text, vbCr, "")
- .InsertBefore Text:="参考答案:"
- .InsertAfter Text:=vbCr
- .HomeKey 5
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|