Inserting image in a particular cell in VBA [Solved/Closed]

Report
-
 AdiK -
Hello All,

I wanna insert an image into the Activecell but the image is getting inserted into the same default area. Kindly help me regarding this by checking the code below

Sub pics()

Range("Q1").Activate

ActiveSheet.Pictures.Insert ("E:\personal\adi.jpg")

End Sub

3 replies

Posts
2638
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
August 4, 2020
432
Hi adikademani,

To place the image in the active cell instead of Q1 then replace:
Range("Q1").Activate
By:
ActiveCell.Activate

Best regards,
Trowa
Hi Trowa,

thanks for the quick reply, but the image is still not getting inserted into that particular cell. For example, how do i insert a picture into the Cell Q1 ?
Posts
2638
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
August 4, 2020
432
There must be some misunderstanding, because the code you posted does that. Where does the picture go if not Q1?
>
Posts
2638
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
August 4, 2020

Hi Trowa,

Thanks a lott, the issue is solved.
I need some more help with the following. I am trying to insert an image into a particular cell by calling the value stored in the variable via an InputBox. The following code is showing error. Kindly help me. Thank u :)

Sub image()

Dim x As String
x = InputBox("insert image name")


Range("E5").Select

ActiveSheet.Pictures.Insert( _
"G:\PEP\04.Kaizen\KAIZEN Audit\02 Auditfragebögen\5S questionaire\ x "). _
Select

End Sub
Posts
2638
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
August 4, 2020
432
Hi Adikademani,

You included the x within the path string. Since it is a variable you need to place it outside like:
"G:\PEP\04.Kaizen\KAIZEN Audit\02 Auditfragebögen\5S questionaire\" & x)

Also make sure that you enter the full file name (so with extention) when prompted by the inputbox for the code you created.

Best regards,
Trowa

Monday, Tuesday and Thursday are usually the days I'll respond. Bear this in mind when awaiting a reply.
Thanks a lott :)