有没有更好的,EXCEL VBA

[复制链接]
查看11 | 回复1 | 2011-5-28 22:00:10 | 显示全部楼层 |阅读模式
Dim num As Integer
Dim counter As Integer
Dim counter0 As Integer
num = 0
counter0 = 0
counter = 0
For sheetfor = 1 To ThisWorkbook.Sheets.Count
For i = 1 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row

If Not Sheets(sheetfor).Range("d" & i).MergeCells Then

If Sheets(sheetfor).Range("d" & i)"本月表数" Then

counter = Val(Sheets(sheetfor).Range("D" & i)) - Val(Sheets(sheetfor).Range("c" & i))

Sheets(sheetfor).Range("c" & i) = Sheets(sheetfor).Range("D" & i) '将某行D列数据付给C列

Sheets(sheetfor).Range("d" & i).ClearContents '删除某行D列

num = num + 1

counter0 = counter + counter0

End If

End If
Next i
MsgBox "共剪贴了" & ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row & "个记录"
Next sheetfor
MsgBox "共剪贴了" & num & "个记录,共计电量" & counter0

回复

使用道具 举报

千问 | 2011-5-28 22:00:10 | 显示全部楼层
Private Sub CommandButton1_Click() Dim pages As Long pages = ExecuteExcel4Macro("Get.Document(50)") MsgBox pagesEnd Sub取得页数,不知道你的具体需要,适当修改咯。Private Sub CommandButton1_Click() If MsgBox("该文档共计" & ExecuteExcel4Macro("Get.Document(50)") & "页,是否打印?", vbYesNo + vbExclamation, "打印提示") = vbYes Then ActiveShe...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行