2011-11-29 205 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.