title: Insert picture corresponding to cell value using excel macro
body: <p>I'm using the macro below to insert the picture corresponding to the value in Cell P2 into cell Q2.</p>
  
  <p>This works for the one cell selected (P2 in this case).</p>
  
  <p>I want to create a loop to do the same action for the rows in Column P range (P2:P500) that are not blank.</p>
  
  <pre><code>Sub Picture()
  
   Range("Q2").Select 
   Dim picname As String
  
   picname = "C:\Users\kisnahr\Pictures\Test\" &amp; Range("P2") &amp; ".bmp" 'Link to the picture
   ActiveSheet.Pictures.Insert(picname).Select
  
   With Selection
   .Left = Range("Q2").Left
   .Top = Range("Q2").Top
   .ShapeRange.LockAspectRatio = msoFalse
   .ShapeRange.Height = 80#
   .ShapeRange.Width = 80#
   .ShapeRange.Rotation = 0#
   End With
  
   Range("Q10").Select
   Application.ScreenUpdating = True
  
   Exit Sub
  
   ErrNoPhoto:
   MsgBox "Unable to Find Photo" 'Shows message box if picture not found
   Exit Sub
   Range("P20").Select
  
   End Sub 
  </code></pre>