|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Private Sub Worksheet_Change(ByVal Target As Range) '单独打印
- If Target = "" Then Exit Sub
- If Target.Address <> "$E$33" And Target.Address <> "$G$33" Then Exit Sub
- Dim arr, p$, c As Range, l%, j&, w
- If Target.Address = "$E$33" Then l = 5 Else l = 4
- a = Array("", "", "", "", "C11", "C7", "C9", "", "C13", "", "C17", "C15")
- Me.PageSetup.PrintArea = "$A$1:$H$28"
- p = ThisWorkbook.Path & ""
- With Sheets("考生信息")
- Set c = .Columns(l).Find(Target.Value, , , 1)
- If Not c Is Nothing Then
- arr = .Cells(c.Row, 1).Resize(, 11)
- With Me.Image1
- w = .Width
- If Dir(p & arr(1, 9)) <> "" Then .Picture = LoadPicture(p & arr(1, 9)) Else .Picture = LoadPicture("")
- .PictureSizeMode = 1
- .Width = w * 0.99
- .Width = w
- For j = 4 To UBound(a)
- If Len(a(j)) Then Range(a(j)).Value = arr(1, j)
- Next
- Me.PrintOut
- .Picture = LoadPicture("")
- End With
- Else
- MsgBox "没有查到"
- End If
- End With
- End Sub
复制代码 |
|