可以考虑使用VBA实现,代码如下
Sub 统计()YorN = MsgBox("是否已选择正确的区域,所选区域为:" & Chr(13) & Selection.Address(0, 0), vbYesNo, "确认所选区域")If YorN = vbNo ThenMsgBox "程序即将结束,请重新选择区域并再次该程序"Exit SubEnd IfSet d = CreateObject("Scripting.Dictionary")For Each i In Selectiond(i.Value) = d(i.Value) + 1Next ik = d.keyst = d.itemscol = [a1].End(xlToRight).Column + 2Cells(2, col).Resize(d.Count, 1) = Application.Transpose(k)Cells(2, col + 1).Resize(d.Count, 1) = Application.Transpose(t)Cells(1, col).Resize(1, 2) = Array("项", "个数")Set d = NothingEnd Sub
具体步骤可参考以下视频
注:如Excel打开后无“开发工具”选项卡,请在“Excel选项”——“常规”——勾选上“在功能区显示开发工具选项卡”或自行百度