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: 27
Default inserting graphics in a conditional formatting

Untested Codes

Sub SavePicture_Location()
Application.ScreenUpdating = False
Range("Z2").Select ' Modify to suit(If required)
Dim WB As Workbook
Dim Sh As Worksheet
Dim rng As Range
Dim mypic As Picture
Dim res As Variant, ans As Variant
Set WB = ActiveWorkbook
res = Application.GetOpenFilename("Image Files (*.jpg), *.jpg")
If res = False Then Exit Sub
Set Sh = ActiveSheet
Set rng = ActiveCell
Set mypic = Sh.Pictures.Insert(res) ' Do nto use. Only if you want a
sample picture over that cell
With mypic
.Top = rng.Top
.Left = rng.Left
.Locked = False
mypic.ShapeRange.LockAspectRatio = msoFalse ' False of True, up
to you. If True then remove one of the below modifications to size
mypic.ShapeRange.Width = 245.1 ' Modify Width to suit
mypic.ShapeRange.Height = 185 ' Modify Height to suit
ActiveCell.Offset(-1, 0).Value = res ' Location of the Picture
stored in Range("Z2").Offset(-1,0) or otherwise Range("Z1")
End With
Application.ScreenUpdating = True
End Sub



Sub Insert_Picture_into_sheet()
Application.ScreenUpdating = False
If Range("Z2").Value < "" Then
Range("Z2").Select
Set WB = ActiveWorkbook
res = Range("Z1").Value ' Finds location of Picture
If res = False Then Exit Sub
Set Sh = ActiveSheet
Set rng = ActiveCell
Set mypic = Sh.Pictures.Insert(res) ' Places the picture on the sheet over
the Activecell
With mypic
.Top = rng.Top
.Left = rng.Left
.Locked = False
mypic.ShapeRange.LockAspectRatio = msoFalse ' Same as previous
code
mypic.ShapeRange.Width = 245.1 ' Same as previous code
mypic.ShapeRange.Height = 185 ' Same as previous code

End With
End If
Application.ScreenUpdating = True
end Sub

If you wanted to you could use the "Private Sub
Worksheet_SelectionChange(ByVal Target As Range)" to do the Inserting of the
picture based on the value in the Activecell instead, to save manually
running that code.

Something lik:
If Range("Z2").value 100 then res=Range("Z1").value
If Range("Z2").value 75 and Range("Z1").value < 99 then
res=Range("Y1").value
etc.

Hope this assists you a bit.

Corey....
"vanan" wrote in message
...
I have a sheet1 that pickup up values from sheet2. I want to format cells
in
sheet1 to insert a particular graphics if certain condition is meet. E.g.
if
value <93% , insert red light, if value btw 94% and 97%, insert yellow
light
and so on. Its simple to highlight the cell with colors but replacing with
graphics is tough for me. How do I refer to a cell from a different excel
file which contains multiple sheets?

Thanks



 
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
Conditional Formatting - Inserting Rows Danny Excel Worksheet Functions 1 March 2nd 10 09:39 PM
Can graphics be used with conditional formatting? Chris C Excel Discussion (Misc queries) 3 April 22nd 06 03:18 AM
Conditional Formatting when inserting a row zahoulik Excel Worksheet Functions 2 January 7th 06 03:01 PM
Problem with Conditional Formatting when Inserting a Row JGeniti Excel Programming 2 July 25th 05 08:24 PM
Inserting Graphics Chill Pill Excel Discussion (Misc queries) 0 April 27th 05 03:18 PM


All times are GMT +1. The time now is 06:28 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"