Private Sub ComboBox1_Change()
Dim a As Range
Application.ScreenUpdating = False
With Database
Set a = .Columns("E").Find(ComboBox1, lookat:=xlWhole)
Label1.Caption = a.Offset(, 1)
a.Offset(, 1).CopyPicture '複製成圖片 a.Offset(, 1). 1為傳回上1行程式 a = .Columns("E").後1格儲存格的圖片
With .ChartObjects.Add(1, 1, a.Offset(, 2).Width, a.Offset(, 2).Height) '新增圖表
.Chart.Paste '貼上圖片
.Chart.Export "D:\temp.jpg" '匯出圖表,暫存圖片
.Delete '刪除圖表
End With
Image1.Picture = LoadPicture("D:\temp.jpg") '表單顯示圖片
Kill "D:\temp.jpg" '刪除暫存圖片
End With
Application.ScreenUpdating = True
End Sub
Private Sub UserForm_Initialize()
Dim a As Range
Set d = CreateObject("Scripting.Dictionary")
With Database
For Each a In .Range(.[E2], .[E2].End(xlDown))
d(a.Value) = ""
Next
End With
ComboBox1.List = d.keys
End Sub