答案 0 :(得分:0)
1-保存启用宏的电子表格。 (另存为.xlsm) 2-打开视图选项卡,单击宏,查看宏并进行编辑 3-粘贴以下代码:
Sub Macro0()
'I assume your information is in the column A
With Range("A1:A65000")
'I also assume all CATEGORIES start with the word CATEGORY
'If that is not the case you have to define a list with all GATEGORIES
Set c = .Find("GATEGORY", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
oneBefore = firstAddress - 1
Do
Range("A1", oneBefore).Select
Selection.Merge
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub
请注意我在代码中的评论。 让我知道它是否适合你。
来源:http://msdn.microsoft.com/en-us/library/office/ff839746%28v=office.15%29.aspx