|
感觉对于大神来说是很简单的,自己弄的就复杂
具体表内容为
宏内容为
Sub h1()
Dim a, b, c, d, e, f
b = Cells(Rows.Count, 11).End(xlUp).Row
a = Cells(b, Columns.Count).End(xlToLeft).Column
c = Cells(b, a - 3) - Cells(b - 1, a - 3)
d = Cells(b, a - 2) - Cells(b - 1, a - 2)
e = Cells(b, a) - Cells(b - 1, a)
Range("d" & b).Select
ActiveCell.FormulaR1C1 = c
ActiveCell.Offset(, -1) = "增加"
If Val(c) < 0 Then
ActiveCell.Value = -c
ActiveCell.Offset(, -1) = "下降"
End If
ActiveCell.Offset(, -2) = "当日新增工单"
ActiveCell.Offset(, 1) = "户"
ActiveCell.Offset(, -2).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 15773696
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Range("d" & b + 1).Select
ActiveCell.FormulaR1C1 = d
ActiveCell.Offset(, -1) = "增加"
If Val(d) < 0 Then
ActiveCell.Value = -d
ActiveCell.Offset(, -1) = "下降"
End If
ActiveCell.Offset(, -2) = "当日竣工工单"
ActiveCell.Offset(, 1) = "户"
ActiveCell.Offset(, -2).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 15773696
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Range("d" & b + 2).Select
ActiveCell.FormulaR1C1 = e
ActiveCell.Offset(, -1) = "增加"
If Val(e) < 0 Then
ActiveCell.Value = -e
ActiveCell.Offset(, -1) = "下降"
End If
ActiveCell.Offset(, -2) = "当日剩余工单"
ActiveCell.Offset(, 1) = "户"
ActiveCell.Offset(, -2).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 15773696
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
End Sub
- Sub h1()
- Dim a, b, c, d, e, zj
- b = Cells(Rows.Count, 11).End(xlUp).Row
- a = Cells(b, Columns.Count).End(xlToLeft).Column
- c = Cells(b, a - 3) - Cells(b - 1, a - 3) '当日新增
- d = Cells(b, a - 2) - Cells(b - 1, a - 2) '当日竣工
- e = Cells(b, a) - Cells(b - 1, a) '当日剩余
- zj = IIf(c > 0, "增加", "下降") '增加or下降
- Cells(b, "D").Resize(1, 4) = Array("当日新增工单", zj, Abs(c), "户")
-
- zj = IIf(d > 0, "增加", "下降")
- Cells(b + 1, "D").Resize(1, 4) = Array("当日竣工工单", zj, Abs(d), "户")
-
- zj = IIf(e > 0, "增加", "下降")
- Cells(b + 2, "D").Resize(1, 4) = Array("当日剩余工单", zj, Abs(e), "户")
-
- Cells(b, "D").Resize(1, 3).Interior.Color = 15773696 '调单元格颜色
- Cells(b, "D").Resize(1, 3).Font.ThemeColor = xlThemeColorDark1 '调字体格式
- End Sub
复制代码
|
|