Placing a variable inside a URL

rickincanada

Board Regular
Joined
Aug 31, 2010
Messages
61
Hi there, I'm pretty new at the VB side of excel and am having some problems sorting through this issue. I've researched the web and cannot find the answer I need. Here's what I'm trying to do:

I have a cell on a sheet in which I insert an image on using the following macro:

Sub getImage()
Dim myPic As Object
Application.ScreenUpdating = 0
Set myPic = Sheets(1).Pictures.Insert( _
"http://testurl.com/private_folder/clients/dealer1/header.jpg")
With myPic
.Top = [a1].Top
.Left = [a1].Left
.ShapeRange.Height = [a1].RowHeight * 1
End With
Application.ScreenUpdating = -1
Set myPic = Nothing
End Sub

This works good however now I want to add a parameter to the middle of this url using a value from a cell. So that if cell "A2" = "Smiths" my url comes out looking like this:

"http://testurl.com/private_folder/clients/Smiths/header.jpg"

Thanks in advance for helping me with this!

Rick
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try

Code:
Set myPic = Sheets(1).Pictures.Insert( _
"http://testurl.com/private_folder/clients/" & Range("A2").value & "/dealer1/header.jpg")
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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