zoukankan      html  css  js  c++  java
  • 使用宏实现透视表部分功能,将AB列数据合并统计.

    功能:1.筛选B列;2.将A列中的值按照筛选后的结果进行合计.

    这个特殊点是按照月日进行筛选的.

    Sub count_a()
    Dim sh As Worksheet
    Set sh = ActiveSheet
    Range("C2:D" & [D65536].End(3).Row).Clear
    For line_b = 2 To [B65536].End(3).Row
    If Len(Cells(line_b, "B").Value) <> 10 Then
    'Cells(line_b, "B").Value = Left(Cells(line_b, "B").Value, 5) & "0" & Right(Cells(line_b, "B").Value, 4)
    Cells(line_b, "B").Value = Format(Cells(line_b, "B").Value, "YYYY/MM/DD")
    End If
    Next

    arr = ActiveSheet.Range("B2:B" & [B65536].End(3).Row)
    Set dict = CreateObject("scripting.dictionary")
    For j = 2 To UBound(arr)
    If LenB(Right(arr(j, 1), 5)) > 0 Then
    dict(Right(arr(j, 1), 5)) = ""
    End If
    Next j

    k = dict.keys
    Dim count_a
    For dict_i = 0 To dict.Count - 1
    count_a = 0
    Key = k(dict_i)
    'MsgBox Key
    Cells(dict_i + 2, "C").Value = Format(Key, "MM/DD")
    For line_a = 2 To [a65536].End(3).Row
    If Right(Cells(line_a, "B").Value, 5) = Key Then
    count_a = count_a + Cells(line_a, "A").Value
    End If
    Next
    Cells(dict_i + 2, "D").Value = count_a

    Next


    End Sub

  • 相关阅读:
    Mysql日志管理
    Mysql 安全和DCL语句
    Mysql DDL语句之视图
    Mysql增删改查(DML、DQL)
    Mysql操作之部分DDL语句
    如何做事情
    temp
    asp.net入门
    希望尽快回忆起来
    需求?
  • 原文地址:https://www.cnblogs.com/ylpb/p/7455371.html
Copyright © 2011-2022 走看看