|
楼主 |
发表于 2018-7-13 14:10
|
显示全部楼层
其实我真的在学习,在消化。可能消化的过程 ,是以 实用为主,遇到哪块有问题,学哪块,不够系统。
经过两天的摸索,我自己搞定了单个 sheet表的,读取出来所有的数据。还没加上遍历
写的方法很笨拙,但达到目的了。过几天有时间再改改。
- Sub 读取点位数()
- Dim i, j, k, sl, sum, arr, brr()
- Application.Calculation = xlCalculationManual '手动重算
- Sheet2.Activate
- Sheet2.Range("D2:I24").ClearContents
- ‘Title = Split("行业 测评点位 得分 测评项目数")
- Rows1 = Sheets("李明数据").UsedRange.Rows.Count
- arr = Sheet1.Range("a1:j" & Rows1)
- ReDim brr(1 To UBound(arr, 1), 1 To 4)
- ReDim crr(1 To UBound(arr, 1), 1 To 8)
- sk = 0
- j = 1
- With Sheets("李明数据")
- For i = 1 To UBound(arr, 1) - 1
- If arr(i, 1) <> "" And arr(i, 3) <> "" Then ' And arr(i, 3) <> "研究点位"
- k = Sheet1.Cells(i, 1).MergeArea.Rows.Count
- sum = 0
- If k = 1 Then '单行表格不计入行数
- sk = Sheet1.Cells(i + 1, 1).MergeArea.Rows.Count
- End If
- If i > 4 And arr(i - 1, 1) = "研究点位" Then '单行表格不计入行数
- stpk = stpk + oldk
- End If
- If k = sk Then '单行表格不计入行数
- For sl = 1 To k
- If arr(i, 5) > 0 Then
- sum = sum + Val(arr(i + sl - 1, 5))
- crr(sl + stpk, 1) = crr(sl + stpk, 1) + Val(arr(i + sl - 1, 10))
- End If
- Next
- brr(j, 1) = arr(i, 1)
- brr(j, 2) = arr(i, 6)
- brr(j, 3) = sum
- brr(j, 4) = k
- j = j + 1
- End If
- End If
- If k > 1 Then
- oldk = k
- End If
- Next
- End With
- Sheet2.[J2].Resize(UBound(brr, 1) - 1, UBound(brr, 2)) = brr
- Sheet2.[N2].Resize(UBound(crr, 1) - 1, 1) = crr
- Application.Calculation = xlCalculationAutomatic '自动重算
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|