|
D13:tytytty交作业,辛苦老师
1 (1)
- Private Sub CommandButton1_Click()
- Dim i%, rg As Range, xx As Long, x%, x1%
- For i = 2 To Range("A65536").End(xlUp).Row
- If Month(Cells(i, 1)) <> Month(Cells(i + 1, 1)) Then
- If rg Is Nothing Then
- Set rg = Rows(i + 1)
- Else
- Set rg = Union(rg, Rows(i + 1))
- End If
- End If
- Next i
- rg.Select
- Selection.Insert Shift:=xlDown
- xx = Range("A65536").End(xlUp).Row + 1
- Range("A2:A" & xx).Select
- Selection.SpecialCells(xlCellTypeBlanks) = "小计"
- For i = 2 To Range("a65536").End(xlUp).Row
- If Cells(i, 1) <> "小计" Then
- x = x + Cells(i, 3)
- x1 = x1 + Cells(i, 4)
- Else
- Cells(i, 3) = x
- Cells(i, 4) = x1
- x = 0
- x1 = 0
- End If
- Next
- End Sub
复制代码 1 (2)- Sub test()
- Dim i%, x%, x1%
- For i = Range("a65536").End(xlUp).Row + 1 To 3 Step -1
- If Month(Range("a" & i)) <> Month(Range("a" & i - 1)) Then
- Rows(i).Insert
- Cells(i, 1) = "小计"
- End If
- Next
- For i = 2 To Range("a65536").End(xlUp).Row
- If Cells(i, 1) <> "小计" Then
- x = x + Cells(i, 3)
- x1 = x1 + Cells(i, 4)
- Else
- Cells(i, 3) = x
- Cells(i, 4) = x1
- x = 0
- x1 = 0
- End If
- Next
- End Sub
复制代码 2
- Private Sub CommandButton2_Click()
- Dim m As Long
- m = Range("C65536").End(xlUp).Row
- Range("C2:C" & m).SpecialCells(xlCellTypeBlanks).Offset(, 2).Value = 1
- End Sub
复制代码 3- Private Sub CommandButton3_Click()
- Dim x%
- For x = 2 To Range("E65536").End(xlUp).Row
- Cells(x, 5).ClearContents
- Next
- Range("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
- End Sub
复制代码
11.xls
(35.5 KB, 下载次数: 1)
|
评分
-
查看全部评分
|