|
呵呵,失业已久,练练手,免得生疏了
以此为例
https://highot.us/thread-333297-1-1.html
https://highot.us/thread-333288-1-1.html
谈谈EXCEL数据分析实战
粽子统计
1、数据采集此过程最繁重,每页复制、粘贴形成文本。
数据量过大时,应请管理员直接提供该主题的数据库。
2、重建ID与UID。
3、数据筛选,去除无关数据,以UID为筛选目标,
不要以ID为筛选目标,因为回贴中会包含ID,而UID是唯一无人使用的。
4、理清思路,调试VBA代码,分析校验数据。
5、形成统计表格及报告。
附:VBA代码
Sub Macro1()
'
' Macro1 Macro
'
'
Dim x As Integer
Dim y As Integer
Dim n As Integer
For x = 2 To 8
n = 0
For y = 1 To 718
If Sheet3.Cells(x, 6) = Sheet4.Cells(y, 1) Then '查找粽子
If y - 1 > 0 Then '粽子的前一行不能为空
If Sheet4.Cells(y, 1) <> Sheet4.Cells(y - 1, 1) <> Sheet4.Cells(y + 1, 1) Then '粽子本身及其前后不能是同一UID
If Sheet3.Cells(x, 3) = Sheet4.Cells(y - 1, 1) Or Sheet3.Cells(x, 3) = Sheet4.Cells(y + 1, 1) Then '查找棕叶
If Sheet3.Cells(x, 9) = Sheet4.Cells(y - 1, 1) Or Sheet3.Cells(x, 9) = Sheet4.Cells(y + 1, 1) Then '查找棕叶
n = n + 1 '计数
Sheet4.Cells(y, 2) = x - 1 '为后继校验代码作标记
End If
End If
End If
End If
End If
Next
Sheet3.Cells(x, 11) = n
Next
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
评分
-
查看全部评分
|