View Single Post
  #2   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

"Defoes Right Boot"

First off, you should post with a name. It's only polite to let us know who
you are.

You can use the worksheet's change (if A1 is directly entered) or calculate
event (if A1 contains a formula) to hide or show the bitmap (change the
visible property to either true or false) based on the value in A1. Copy the
first procedure, right-click on the worksheet tab, select "View Code" and
paste into the window that appears. Copy the second procedure, and paste
into a standard codemodule. Change the file and path, and you can lose the
MsgBoxes as well.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
HandleBMP
Application.EnableEvents = True
End If
End Sub

Sub HandleBMP()
Dim myCell As Range
Set myCell = Selection

On Error Resume Next
If Range("A1").Value = 1 Then
MsgBox "Inserting"
ActiveSheet.Shapes("A1 Picture").Delete
Range("B1").Select
ActiveSheet.Pictures.Insert( _
"C:\Path\Filename.BMP").Select
Selection.Name = "A1 Picture"
Else
MsgBox "Deleting"
ActiveSheet.Shapes("A1 Picture").Delete
End If

myCell.Select
End Sub



"Defoes Right Boot" wrote in
message ...
I need to show a bitmap only if (for example) cell A1 = 1 but not if A1 =

0.

Is this possible using conditional formatting or other method?

Thanks