|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
使用的是vba
- Sub test()
- Call 填充G列
- Call 字典求和
- Call 清空G列
- End Sub
- Private Sub 填充G列()
- For i = 2 To 20
- If Left(Cells(i, 2), 3) = "联系人" Then
- Cells(i, 7) = Right(Cells(i, 2), Len(Cells(i, 2)) - 4)
- ElseIf Left(Cells(i, 2), 3) <> "联系人" And Len(Cells(i, 2)) <> 0 Then
- Cells(i, 7) = Cells(i - 1, 7)
- End If
- Next
- End Sub
- Private Sub 清空G列()
- Columns("G:G").Clear
- End Sub
- Private Sub 字典求和()
- Dim dic As New Dictionary
- For Each Rng In Range("G2:g20")
- Name = Rng.Value
- If Rng.Offset(0, -1) <> "" And IsNumeric(Rng.Offset(0, -1).Value) Then
- If dic.Exists(Name) Then
- dic(Name) = dic(Name) + Rng.Offset(0, -1)
- Else
- dic(Name) = Rng.Offset(0, -1)
- End If
- End If
- Next Rng
- x = dic.Keys
- y = dic.Items
-
-
- Range("h3").Resize(UBound(x) + 1) = Application.Transpose(x)
- Range("i3").Resize(UBound(x) + 1) = Application.Transpose(y)
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|