Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Defoes Right Boot
 
Posts: n/a
Default How do I conditionally insert an image (.bmp file)?

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
  #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



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
M John
 
Posts: n/a
Default How do I conditionally insert an image (.bmp file)?

Mr. Deitrick,
I have a similar question (at least I think it just builds on the previous
post below):

I would like to have a macro that inserts one of 5 symbols to a cell based
on the value in the cell. What I'm aiming for is something similar to the
tables Conumer Reports uses to rate the items they evaluate: Red circle,
half full (upper half) red circle, empty circle, black half full (lower)
circle, and black full circle.

I have the images are ready to go and the code below will work for inserting
an image for a single "if" statement, but I'm not getting the (I'm guessing)
nested statements correct.

Any help you can provide will be most appreciated.

Many thanks in advance,
M John

"Bernie Deitrick" wrote:

"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




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default How do I conditionally insert an image (.bmp file)?

Dear Bernie,
I had a similar question earlier and had benmarked what you recommended. It
was very useful and we were able to add in different bmp files based on
different scenarios. However, my next problem is - if this worksheet is
protected, the bitmap file doesn't change according to the condition. Since
the intention is just to allow user clicking a particular cell for choosing
the company name, then the logo is popped up automatically, we don't want to
open up the rest of the spreadsheet. Here below is what we've put and
appreciate your advice on how could we fix this problem:
********************************************
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$6" 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("G6").Value = "Vendor" Then
ActiveSheet.Shapes("B1 Picture").Delete
ActiveSheet.Shapes("A1 Picture").Delete
Range("A1").Select
ActiveSheet.Pictures.Insert( _
"P:\Merchandising\GSL Logo Picture.bmp").Select
Selection.Name = "A1 Picture"
Else

ActiveSheet.Shapes("A1 Picture").Delete
End If

If Range("G6").Value = "Customer" Then
ActiveSheet.Shapes("B1 Picture").Delete
ActiveSheet.Shapes("A1 Picture").Delete
Range("A1").Select
ActiveSheet.Pictures.Insert( _
"P:\Merchandising\Solito Logo Picture.bmp").Select
Selection.Name = "B1 Picture"
Else

ActiveSheet.Shapes("B1 Picture").Delete
End If

myCell.Select
End Sub
********************************************

Thank you very much,
ATang


"Bernie Deitrick" wrote:

"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




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
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
Challenging Charting C TO Charts and Charting in Excel 0 January 17th 05 06:57 PM
insert image in head excel file? ducenis Excel Discussion (Misc queries) 2 January 15th 05 12:14 AM
How do I insert an Excel file into a PowerPoint Presentation slid. Barb Excel Worksheet Functions 1 December 11th 04 04:23 PM
How do I insert an Excel file into a PowerPoint Presentation slid. Barb Excel Discussion (Misc queries) 1 December 11th 04 04:22 PM


All times are GMT +1. The time now is 11:23 AM.

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"