augejevgenij
New Member
- Joined
- Mar 3, 2021
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hello,
I just started to use VBA and would really appreciate if someone could help me out. I would like to view images according to a path stored in a database. The images should refresh if a value in a specific cell is changed. I already figured out how to import one image according to the database, which is connected to that specific cell through INDEX and MATCH formulas. Unfortunately my knowledge is not enough to write a code which allows to import several images at the same time. Also it seems like sometimes previous images wont get removed and a new image is getting imported on top of the old one. If there is no image at all or no matching path in the database, a run-time error is exposed.
Is it even possible to find a clean solution for my problem and import several images at the same time? I would be really thankful if somebody could lead me in the right direction and at least help me deal with the runtime errors. Huge thanks in advance!
Database:
Screen + specific Cell (red):
Code used to import first image:
The full file and images in a ZIP:
VBA help for importing images from file
I just started to use VBA and would really appreciate if someone could help me out. I would like to view images according to a path stored in a database. The images should refresh if a value in a specific cell is changed. I already figured out how to import one image according to the database, which is connected to that specific cell through INDEX and MATCH formulas. Unfortunately my knowledge is not enough to write a code which allows to import several images at the same time. Also it seems like sometimes previous images wont get removed and a new image is getting imported on top of the old one. If there is no image at all or no matching path in the database, a run-time error is exposed.
Is it even possible to find a clean solution for my problem and import several images at the same time? I would be really thankful if somebody could lead me in the right direction and at least help me deal with the runtime errors. Huge thanks in advance!
Database:
Screen + specific Cell (red):
Code used to import first image:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$CG$1" Then
Shapes(1).Delete
Pictures.Insert(ActiveSheet.Range("V21").Value).Select
With Selection
.Height = ActiveSheet.Range("V21:CI40").Height
.Width = ActiveSheet.Range("V21:CI40").Width
.Left = ActiveSheet.Range("V21").Left
.Top = ActiveSheet.Range("V21").Top
End With
Range("C3").Select
End If
End Sub
The full file and images in a ZIP:
VBA help for importing images from file