Image VBA for Multiple Rows and Columns

Ivy_1011

New Member
Joined
Mar 19, 2021
Messages
18
Platform
  1. Windows
I have the chart below with numbers, below the number I want to insert an image and have the image change every time the number is changed, I plan to have 4 separate rows where the image populates. Below the source code I have. I am having two problems. below each number should be an image that automatically populates once the number is added.

1-Apply to multiple columns and rows
2-Mix-match type run-time error


Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

Dim myPict As Picture
Dim PictureLoc As Integer

If Target.Address = Range("A2").Address Then

ActiveSheet.Pictures.Delete

PictureLoc = "C:\Users\isaac\Downloads\inser\" & Range("A2").Value & ".jpg"

With Range("A3")


Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
.RowHeight = myPict.Height
myPict.Top = .Top + .Height / 2 - myPict.Height / 2
myPict.Left = .Left + .Width / 2 - myPict.Width / 2

myPict.Placement = xlMoveAndSize

End With

End If

End Sub

321





112






 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,214,954
Messages
6,122,462
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top