|
Private Sub CommandButton1_Click()
Dim rn As Range
zd = ComboBox1.Text
If zd = "" Then MsgBox "请输入字段名称!": Exit Sub
With Sheets("CoC No.交付资料")
r = .Cells(Rows.Count, 5).End(xlUp).Row
ar = .Range("a1:t" & r)
Set rn = .Range("e1:e" & r).Find(zd, , , , , , 1)
End With
If rn Is Nothing Then Exit Sub
xh = rn.Row
With Sheets("COC of")
.[i2] = zd
.[a8] = ar(xh, 13)
.[g8] = ar(xh, 15)
.[b16] = ar(xh, 3)
.[d18] = ar(xh, 2)
.[d19] = "Revision:" & ar(xh, 4)
.[e19] = ar(xh, 6)
.[i16] = ar(xh, 8)
.[a22] = ar(xh, 13)
.[e23] = ar(xh, 12)
.[e24] = ar(xh, 14)
.[d30] = ar(xh, 7)
.Copy
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\COC of 123" & zd & ".xlsx"
End With
ActiveWorkbook.Close
End
End Sub
Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("CoC No.交付资料")
r = .Cells(Rows.Count, 5).End(xlUp).Row
If r < 2 Then MsgBox "CoC No.交付资料为空!": End
ar = .Range("e1:e" & r)
End With
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
d(Trim(ar(i, 1))) = ""
End If
Next i
Me.ComboBox1.List = d.keys
End Sub
|
|