Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro coding using GIF

I created a status report with the following outcomes in MS Excel:

Stat(Column A3) = 0 Not Started (Blue Color)
Stat = 1 On track (Green Color)
Stat =2 Slightly behind (Yellow color)
Stat = 3 Needs Immediate attention (Red Color)

I used the following equation:

=If (A3=0,"BLUE",IF(A3=<=1,"GREEN",IF(A3<=2,"YELLOW", IF A3=3,"RED",""))))

This works fine.

However, Instead of having A3 field colored, I want to use picture that has
the color instead. I tried to use a macro to do just that am having problem.
Here is what I want to similar meaning to the below statement in Macro

=If
(A3=0,"lightblue.gif",IF(A3=<=1,"lightgreen.gif",I F(A3<=2,"lightyellow.gif",
IF A3=3,"lightred.gif",""))))

I would appreciate anybody's assistant. Thank you.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Macro coding using GIF

Drop an Image control (from the Controls command bar) to the desired
location on the worksheet, then use code like

Sub InsertPicture()
Const RED_PIC = "C:\Whatever\Red.gif"
Const BLUE_PIC = "C:\Whatever\Blue.gif"
Const GREEN_PIC = "C:\Whatever\Green.gif"
Dim ImageFileName As String

With Worksheets("Sheet2")

If .Range("A3").Value <= 1 Then
ImageFileName = RED_PIC
ElseIf Range("A3").Value <= 3 Then
ImageFileName = BLUE_PIC
ElseIf Range("A3").Value <= 5 Then
ImageFileName = GREEN_PIC
End If

.OLEObjects("Image1").Object.Picture = _
LoadPicture(ImageFileName)
End With
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"kami" wrote in message
...
I created a status report with the following outcomes in MS Excel:

Stat(Column A3) = 0 Not Started (Blue Color)
Stat = 1 On track (Green Color)
Stat =2 Slightly behind (Yellow color)
Stat = 3 Needs Immediate attention (Red Color)

I used the following equation:

=If (A3=0,"BLUE",IF(A3=<=1,"GREEN",IF(A3<=2,"YELLOW", IF
A3=3,"RED",""))))

This works fine.

However, Instead of having A3 field colored, I want to use picture that
has
the color instead. I tried to use a macro to do just that am having
problem.
Here is what I want to similar meaning to the below statement in Macro

=If
(A3=0,"lightblue.gif",IF(A3=<=1,"lightgreen.gif",I F(A3<=2,"lightyellow.gif",
IF A3=3,"lightred.gif",""))))

I would appreciate anybody's assistant. Thank you.


Reply
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
HELP - coding on Macro! Eric Excel Worksheet Functions 3 February 21st 08 12:26 AM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM
Need VB Coding Help for a Macro Tom Ogilvy Excel Programming 0 August 26th 04 08:46 PM
Need VB Coding Help for a Macro Trevor Shuttleworth Excel Programming 0 August 26th 04 08:39 PM
macro coding Andrew[_37_] Excel Programming 1 July 28th 04 06:06 AM


All times are GMT +1. The time now is 11:35 PM.

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

About Us

"It's about Microsoft Excel"