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

- Nov 1, 2016 at 08:52 AM - Latest reply:  AdiK - Nov 9, 2016 at 02:44 PM
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
See more 

6 replies

Posts
2448
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 20, 2018
Nov 1, 2016 at 11:27 AM
0
Thank you
Hi adikademani,

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

Best regards,
Trowa
0
Thank you
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
2448
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 20, 2018
- Nov 1, 2016 at 11:45 AM
There must be some misunderstanding, because the code you posted does that. Where does the picture go if not Q1?
adikademani >
Posts
2448
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 20, 2018
- Nov 2, 2016 at 06:22 AM
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
2448
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 20, 2018
Nov 8, 2016 at 11:47 AM
0
Thank you
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 :)