2011-11-29 170 views
0

我有大約10張圖片,但是我想根據用戶的選擇從一個組合框中選擇四個或五個圖片。但是,我想知道如何確保所選圖像與ComboBox的標籤相匹配。將圖像保存在excel表單上可以嗎?這就是爲什麼我不想要下面的風格。是否可以調整圖像的大小?Excel VBA圖片

Sub update_data() 
    Sheet1.Cells(2, 2) = Sheet1.ComboBox1.Value 
    Sheet1.Image1.Picture = LoadPicture(VBAProject.ThisWorkbook.Path & "\pics\" &  Sheet1.ComboBox1.Value & ".jpg") 
End Sub 

回答

0

您可以使用,如果然後選擇。

例如

If range("a1") = "Your Value" Then 
Range("A1").select 
Activesheet.Pictures.insert and your file path.