this nice macro, courtesy by rorya from EE, inserts graphics into Column D, linking them. The network paths for all these graphics (hyperlinks) are all located in Column C.
This great macro works just fine.
Could somebody help me tweak this code with the following requirements:
Line 15: The column letter should not be hard coded (that was my initial requirement) but dynamic, i.e. line 15 should be based on the column of the currently selected cell, ie. the column letter is to be dynamic.
Help is much appreciated. Thank you very much in advance.
' by rorya from EE
Dim C As Range
Dim Image As Picture
If MsgBox("Would you like to add pictures to the active worksheet, linking them?" & vbCrLf & vbCrLf & _
"There must be network paths as hyperlinks to draw the picture from!", vbQuestion + vbYesNo, "Insert Pictures into Column D") = vbNo Then
On Error Resume Next
For Each C In Range(Range("C2"), Range("C" & Rows.Count).End(xlUp))
Set Image = ActiveSheet.Pictures.Insert(C.Value2) 'linktofile:=msoFalse
If .Height > Application.CentimetersToPoints(4) Then _
.ShapeRange.ScaleHeight Application.CentimetersToPoints(4) / .Height, msoCTrue
.TopLeftCell.RowHeight = Image.Height + 10
If .Height > .Width Then
.Rotation = 90
.IncrementLeft .Height / 2 - .Width / 2
.IncrementTop .Width / 2 - .Height / 2 + 5
.TopLeftCell.RowHeight = Image.Width + 10
Else: .ShapeRange.IncrementTop (5)