LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default Inserting Image based on cell value - Help

Hi everyone

I am trying to create a macro that will look at cell values in range
A1:A2 in sheet1 and insert the correct image on B1:B2.

I.e. values are 2 letters (either number of alphabet e.g. 2C, TH),
image files are value.gif (e.g. picture for TH = TH.GIF)

Path for those pictures are C:\My Documents\ but is it possible to
place all the pictures in sheet2 and look up in sheet2 or anywhere in
that workbook instead of opening the picture under that directory each
time it runs macro?

I have this code from another forum and trying to modify it but it
surely is difficult for me.

Can anyone help?

Thank you everyone!

Sub InsertGIF()
Dim myCell As Range, cell As Range
Dim shp As Shape, rng1 As Range
Dim shp1 As Picture
Dim s As String, sPath As String
Dim s2 As String
Set rng1 = Sheets("sheet1").Range("A1:A2")
Set myCell = Selection


sPath = "C:\My Documents\
If Not Intersect(myCell, rng1) Is Nothing Then
For Each cell In rng1
If cell.Value = "2C" Then
s2 = "2C.GIF"
ElseIf cell.Value = "3C" Then
s2 = "3C.GIf"
ElseIf cell.Value = "4C" Then
s2 = "4C.GIF"
ElseIf cell.Value = "5C" Then
s2 = "5C.GIF"
ElseIf cell.Value = "6C" Then
s2 = "6C.GIF"
End If

With shp1
.Top = cell.Top + (cell.Height - .Height) / 2
.Left = cell.Left + (cell.Width - .Width) / 2
End With

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert an image based on a cell value brig239 New Users to Excel 1 June 3rd 09 07:10 PM
Inserting an image into a cell Trent SC Excel Discussion (Misc queries) 2 April 11th 08 11:37 AM
Inserting an image into a cell Trent SC New Users to Excel 2 April 11th 08 11:37 AM
How do I have an image in a cell based upon a referenced value? Jonathan Neubauer Excel Programming 4 January 30th 05 10:25 PM
How can I change an image based on cell value Adriaan vd Linde Excel Programming 1 July 24th 03 04:25 PM


All times are GMT +1. The time now is 09:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"