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>=3,"lightred.gif",""))))

I would appreciate anybody's assistant. Thank you.

Chip Pearson

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 = _
End With
End Sub

Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
(email on the web site)

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads