|
楼主 |
发表于 2023-3-23 10:58
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
自己研究明白了,哈哈~加您了,请通过。
- Sub 批量打印()
- On Error Resume Next
- Set Rng = Application.InputBox("请选择区域(C列)", "必须选择身份证号码区域", , , , , , 8)
- If Err <> 0 Then Exit Sub
- Sheets("一户一表").Select
- If Len(Rng) <> 18 Then
- arr = Rng
- For i = 1 To UBound(arr)
- If Len(arr(i, 1)) <> 18 Then Exit Sub
- If i = 1 Then
- s = Sheet1.Columns("c").Find(arr(i, 1), , , , , 2).Row
- brr = Sheet1.Range("m" & s).Resize(UBound(arr), 1)
- End If
-
- brr(i, 1) = brr(i, 1) + 1
- Sheet2.Cells(1, "i") = arr(i, 1)
- ' MsgBox "打印"
- ActiveWindow.SelectedSheets.PrintOut
- Next
- Sheet1.Cells(s, "m").Resize(UBound(arr), 1) = brr
- Else
- arr = Rng
- s = Sheet1.Columns("c").Find(arr, , , , , 2).Row
- ss = Sheet1.Range("m" & s)
- If Len(arr) <> 18 Then Exit Sub
- Sheet2.Cells(1, "i") = arr
- ss = ss + 1
- ' MsgBox "打印"
- ActiveWindow.SelectedSheets.PrintOut
- Sheet1.Range("m" & s) = ss
- End If
- End Sub
复制代码 |
|