+ Reply to Thread
Results 1 to 3 of 3

Images

  1. #1
    Forum Contributor
    Join Date
    05-14-2006
    Posts
    104

    Images

    Hello i have inserted a image using control toolbox and set the value of the image to a cartain picture.

    i would like the picture to change depending on a cell value e.g

    if range("a1") = 1 then
    image1.picture = "C:\pictures\apicture.jpg"
    end if
    how do i make this happen as i know the above code is not real it hopefully gives an idea of what i would like thanks

  2. #2
    Registered User
    Join Date
    09-11-2006
    Posts
    56
    After a little testing I got this to work.
    assumes the worksheet is sheet1
    a1 = 1

    Sub pic_test()

    If Cells(1, 1).Value = 1 Then
    ActiveSheet.Pictures.Insert("C:\8973.jpg").Select
    End If
    End Sub

    this assumes this is where the picture is located.
    I recorded a macro and copied the code from the module.
    "There are 10 kinds of people in the world, Those that understand binary, and those that don't."

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Insert Picture according to value

    Please Login or Register  to view this content.

    This goes in the worksheet module

    check here to find that

    http://www.contextures.com/xlvba01.html
    Change all the ranges to suit the size of pic you want, careful with activesheet.pictures.delete
    it will delete all picture in active sheet, except wordart, no idea how to delete wordart using vba
    Last edited by davesexcel; 11-24-2006 at 02:14 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1