Excel笔记
之前看别人做了的,自己做了一个excel数据统计模板,以下是一些excel技巧:
1.求和函数
(1)=SUM(C41:E41)
计算C41-E41和。
(2)=SUMPRODUCT((C5:C25=B41)*(G5:G25=C39)*(F5:F25))
计算F5-F25之间(当前行C列内容=B41且G列内容=C39)的所有单元格之和。
2.取值
(1)='0519'!F42
取名为0519sheet页单元格F42的值。
(2)='E:\T-Link\文档模板\周报模板\[Personal Weekly Report_ZhangHeng.xlsm]Workload'!C5
取当前路径\[文件名]sheetName中单元格C5的值。
3.宏定义
(1)个人工作周报数据统计宏定义:
Sub 按钮1_Click() sr = 4 ' start row sc = 3 ' data start,column for record in Total se = Sheets.Count tn = 12 sr_p = 20 pn = 4 'get sheet name for each member If se > 1 Then For i = 1 To se - 1 Step 1 Cells(sr, 2 + i) = Sheets(i).Name Cells(sr_p, 2 + i) = Sheets(i).Name Next For r = sr + 1 To sr + tn For c = sc To se + 1 If Cells(sr, c) <> "" Then Cells(r, c) = "=" & Cells(sr, c) & "!B" & Trim(Str(r)) End If Next Next For r = sr_p + 1 To sr_p + pn For c = sc To se + 1 If Cells(sr_p, c) <> "" Then Cells(r, c) = "=" & Cells(sr_p, c) & "!B" & Trim(Str(r)) End If Next Next End If End Sub
(2)小组工时统计宏定义:
Sub 统计工作量() ' ' 统计工作量 宏 ' ' 快捷键: Ctrl+a ' sr = 4 'start row sc = 3 'data start column for record in 工作量汇总 se = Sheets.Count 'end column,same with shcou pn = 9 'task number tn = 12 'task type nubmer 'shcou = Sheets.Count 'same with se sr_p = 20 'start row for Project 'get sheet name for each week If se <> 2 Then 'get sheets name and fill row 2 For i = 1 To se - 2 Step 1 Cells(sr, 2 + i) = Sheets(i).Name Cells(sr_p, 2 + i) = Sheets(i).Name Next 'task statistic as task items For c = sc To se 'each week for each sheet,start row For r = sr + 1 To tn + sr 'for each type If Cells(sr, c) <> "" Then Cells(r, c) = "=" & Cells(sr, c) & "!F" & Trim(Str(40 + r - 5)) 'get weekly data End If Next Next For c = sc To se 'each week for each sheet,start row If Cells(sr_p, c) <> "" Then Cells(sr_p + 1, c) = "=" & Cells(sr, c) & "!C" & Trim(Str(49)) 'get weekly data of PROJECT Cells(sr_p + 2, c) = "=" & Cells(sr, c) & "!D" & Trim(Str(49)) 'get weekly data of PROJECT Cells(sr_p + 3, c) = "=" & Cells(sr, c) & "!E" & Trim(Str(49)) 'get weekly data of PROJECT Cells(sr_p + 4, c) = "=" & Cells(sr, c) & "!F" & Trim(Str(49)) 'get weekly data of PROJECT End If Next End If End Sub