|
楼主 |
发表于 2017-7-18 16:40
|
显示全部楼层
Private Sub CommandButton1_Click()
With ActiveSheet
r = 8
t = .Cells(r, 41).Value
m = 7
h = 8
Do
If Cells(m, 41).Value <> "督导" Or Cells(h, 1).Value <> "1" Then
MsgBox "AO不是督导或者A8不是1"
Exit Sub
Else
n = Application.WorksheetFunction.CountIf(.Range("ao:ao"), .Cells(r, 41))
Set wb = Workbooks.Add
wb.SaveAs Filename:="d:\督导打印\" & Format(t, "string") & Format(Now, "yyyymmddhhmmss") & ".xlsx"
.Range("a1:an7").Copy Range("a1")
.Cells(r, 1).Resize(n, 41).Copy Range("a8")
wb.Close True
End If
r = r + n
t = .Cells(r, 41).Value
Loop Until t = ""
End With
MsgBox "已完成督导个人工作表生成"
End Sub
请问代码写在哪个位置?
|
|