View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Toggling Visibility of items with VBA

Here is one way.

Paste both images onto the sheet both in the same print position, and name
them pic_INVOICE and pic_PACKING.

Make them non-visible.

Then add this code, based on the asusmption that INVOICE or PACKING LIST is
in $A$1 (change to suit)


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim shp As Shape
On Error GoTo ws_exit
Application.EnableEvents = False
If Target.Address = "$A$1" Then
If Target.Value = "INVOICE" Then
Me.Shapes("pic_INVOICE").Visible = True
Me.Shapes("pic_PACKING").Visible = False
Else
Me.Shapes("pic_INVOICE").Visible = False
Me.Shapes("pic_PACKING").Visible = True
End If
End If


ws_exit:
Application.EnableEvents = True
On Error GoTo 0
End Sub


This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"SpielbergRules"
<SpielbergRules.2abnjb_1151850004.3659@excelforu m-nospam.com wrote in
message news:SpielbergRules.2abnjb_1151850004.3659@excelfo rum-nospam.com...

Hello,

New to this forum. Created my own invoice for my business and I am
trying to toggle an image that will appear based on the fact of the
invoice being an invoice or a packing list. (You know how they cover
the price and cost columns of a packing list you'd receive when you buy
something.)

In one cell, it will actually say "INVOICE" or "PACKING LIST". I would
like the filled rectangles to be toggled based on those specific words.

I can't seem to be able to make any kind of formula to check that and
make it invisible.

Does anyone know a simple way to do that?

Thanks in advance for any help.

Mike


--
SpielbergRules
------------------------------------------------------------------------
SpielbergRules's Profile:

http://www.excelforum.com/member.php...o&userid=35981
View this thread: http://www.excelforum.com/showthread...hreadid=557674