Results 1 to 2 of 2

Thread: VBA Beginner Insert Images

  1. #1

    VBA Beginner Insert Images



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi

    I have no knowledge of VBA but it does seem to best way for me to automate a spread sheet I need for work. I have tried copying and pasting some code from the web and modifying it to work for my sheet with no success so far.

    Basically I have sheet which contains file names of JPG images stored in a folder. I require a macro which when run will look up images and insert them in the cell over the file name.

    Any help I the code required would be much appreciated.

  2. #2
    Super Moderator Bob Phillips's Avatar
    Join Date
    Mar 2011
    Posts
    1,829
    Articles
    0
    Excel Version
    O365
    Code:
    Sub ImportPictures()
        Dim lastrow As Long
        Dim i As Long
        
        With ActiveSheet
        
            lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
            For i = 1 To lastrow
            
                .Pictures.Insert (.Cells(i, "A").Value)
                .Shapes(.Shapes.Count).Left = .Cells(i, "A").Left
                .Shapes(.Shapes.Count).Top = .Cells(i, "A").Top
            Next i
        End With
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •