#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pic Macro


Hi!
How can I modify this code to work on any pic_ in the worksheet
(dozens) without having to enter each one individulally?
Anytime the active cell = the pic_"name" the picture appears.
When I select a name from a validation list in cell A1 I have to hit
enter in order for the correct picture to appear. Why?

<Start Code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim shp As Shape
On Error GoTo ws_exit
Application.EnableEvents = False
Me.Shapes("pic_Kids").Visible = False
Me.Shapes("pic_Tractor").Visible = False
Me.Shapes("pic_Krause").Visible = False
If Target.Address = "$A$1" Then
Me.Shapes("pic_Kids").Visible = False
Me.Shapes("pic_Tractor").Visible = False
Me.Shapes("pic_Krause").Visible = False
End If
On Error Resume Next
Me.Shapes("pic_" & Target.Value).Visible = True
ws_exit:
Application.EnableEvents = True
On Error GoTo 0
End Sub
<End Code

Any help would be appriciated!
Have a great holiday!!


--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
View this thread: http://www.excelforum.com/showthread...hreadid=557481

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Pic Macro

Have a look at this article for a non VBA approach.

http://www.jkp-ads.com/Articles/ShowPicture00.htm

Cheers
Andy

Brian Matlack wrote:
Hi!
How can I modify this code to work on any pic_ in the worksheet
(dozens) without having to enter each one individulally?
Anytime the active cell = the pic_"name" the picture appears.
When I select a name from a validation list in cell A1 I have to hit
enter in order for the correct picture to appear. Why?

<Start Code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim shp As Shape
On Error GoTo ws_exit
Application.EnableEvents = False
Me.Shapes("pic_Kids").Visible = False
Me.Shapes("pic_Tractor").Visible = False
Me.Shapes("pic_Krause").Visible = False
If Target.Address = "$A$1" Then
Me.Shapes("pic_Kids").Visible = False
Me.Shapes("pic_Tractor").Visible = False
Me.Shapes("pic_Krause").Visible = False
End If
On Error Resume Next
Me.Shapes("pic_" & Target.Value).Visible = True
ws_exit:
Application.EnableEvents = True
On Error GoTo 0
End Sub
<End Code

Any help would be appriciated!
Have a great holiday!!



--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Pic Macro

Try something like this...

Dim shp As Shape

For Each shp In Shapes
shp.Visible = msoFalse
Next shp

--
HTH...

Jim Thomlinson


"Brian Matlack" wrote:


Hi!
How can I modify this code to work on any pic_ in the worksheet
(dozens) without having to enter each one individulally?
Anytime the active cell = the pic_"name" the picture appears.
When I select a name from a validation list in cell A1 I have to hit
enter in order for the correct picture to appear. Why?

<Start Code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim shp As Shape
On Error GoTo ws_exit
Application.EnableEvents = False
Me.Shapes("pic_Kids").Visible = False
Me.Shapes("pic_Tractor").Visible = False
Me.Shapes("pic_Krause").Visible = False
If Target.Address = "$A$1" Then
Me.Shapes("pic_Kids").Visible = False
Me.Shapes("pic_Tractor").Visible = False
Me.Shapes("pic_Krause").Visible = False
End If
On Error Resume Next
Me.Shapes("pic_" & Target.Value).Visible = True
ws_exit:
Application.EnableEvents = True
On Error GoTo 0
End Sub
<End Code

Any help would be appriciated!
Have a great holiday!!


--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
View this thread: http://www.excelforum.com/showthread...hreadid=557481


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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 08:10 PM.

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

About Us

"It's about Microsoft Excel"