Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Cell Mate
 
Posts: n/a
Default VBA Code

I built a code to hide and unhide Bit map shapes. The shapes are "stacked" on
each other and the code is suppose to turn each one on when it's "name"
appears in a cell. In this case B44. The "names" appear below in "". The
problem is that the program just runs through the shapes over and over
instead of stopping on the shape named in the line.

What am I doing wrong?

Thanks!
GW




Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim iCtr As Long
Dim mySfx As Long
Dim myShape As Shape

If Intersect(Target, Range("B44")) Is Nothing Then Exit Sub

For iCtr = 1 To Me.Shapes.Count
Me.Shapes("shape" & iCtr).Visible = False
Next iCtr

With Target
Select Case UCase(.Value)
Case Is = "J-Frame/Belt/Bolt-in": mySfx = 1
Case Is = "J-Frame/Belt/Weld-in": mySfx = 2
Case Is = "J-Frame/Belt/Bolt-in/Integral Baffles": mySfx = 3
Case Is = "J-Frame/Belt/Bolt-in/Integral Baffles/Pillow": mySfx
= 4
Case Is = "J-Frame/Belt/Bolt-in/Single Break Baffle": mySfx = 5
Case Is = "J-Frame/Belt/Bolt-in/Single Break Baffle/Pillow":
mySfx = 6
Case Is = "J-Frame/Belt/Bolt-in/Double Break Baffle": mySfx = 7
Case Is = "J-Frame/Belt/Bolt-in/Double Break Baffle/Pillow":
mySfx = 8
Case Is = "J-Frame/Belt/Weld-in/Integral Baffle": mySfx = 9
Case Is = "J-Frame/Belt/Weld-in/Integral Baffle/Pillow": mySfx =
10
Case Is = "J-Frame/Belt/Weld-in/Single Break Baffle": mySfx = 11
Case Is = "J-Frame/Belt/Weld-in/Single Break Baffle/Pillow":
mySfx = 12
Case Is = "J-Frame/Belt/Weld-in/Double Break Baffle": mySfx = 13
Case Is = "J-Frame/Belt/Weld-in/Double Break Baffle/Pillow":
mySfx = 14
Case Is = "Downward Angle/Belt/Inward/Bolt-in": mySfx = 15
Case Is = "Downward Angle/Belt/Inward/Weld-in": mySfx = 16
Case Is = "Downward Angle/Belt/Inward/Bolt-in/Single Break
Baffle": mySfx = 17
Case Is = "Downward Angle/Belt/Inward/Bolt-in/Double Break
Bolt-in Baffle": mySfx = 18
Case Is = "Downward Angle/Belt/Inward/Weld-in/Single Break
Baffle": mySfx = 19
Case Is = "Downward Angle/Belt/Inward/Weld-in/Double Break
Baffle": mySfx = 20
Case Is = "Angle/Flange": mySfx = 21
Case Is = "Angle/Flange/Single Break Baffle": mySfx = 22
Case Is = "Angle/Flange/Double Break Baffle": mySfx = 23
Case Is = "Angle/Flange/Single Break Bolt-in Baffle": mySfx = 24
Case Is = "Angle/Flange/Double Break Bolt-in Baffle": mySfx = 25
Case Is = "Angle/Belt/Outward/Weld-in": mySfx = 26
Case Is = "Angle/Belt/Outward/Bolt-in": mySfx = 27
Case Is = "Angle/Belt/Inward/Weld-in": mySfx = 28
Case Is = "Angle/Belt/Inward/Bolt-in": mySfx = 29
Case Is = "Angle/Belt/Inward/Weld-in/Integral Baffles": mySfx = 30
Case Is = "Angle/Belt/Inward/Bolt-in/Integral Baffles": mySfx = 31
Case Is = "Channel/Belt/Outward/Weld-in": mySfx = 32
Case Is = "Channel/Belt/Outward/Weld-in/Single Break Baffle":
mySfx = 33
Case Is = "Channel/Belt/Outward/Weld-in/Double Break Baffle":
mySfx = 34
Case Is = "External Mount Stud Bars/Belt": mySfx = 35
Case Is = "Internal Mount Stud Bars/Belt": mySfx = 36
Case Is = "Internal Clamp Design": mySfx = 37
End Select
End With

If mySfx 0 Then
On Error Resume Next
Set myShape = Me.Shapes("shape" & mySfx)
On Error GoTo 0
If myShape Is Nothing Then
MsgBox "error in design--see Gary"
Else
myShape.Visible = True
End If
End If

End Sub
 
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
Change case...help please Terry Excel Worksheet Functions 14 October 2nd 05 12:29 PM
Macro for changing text to Proper Case JPriest Excel Worksheet Functions 3 August 8th 05 09:31 PM
Using other workbooks.. DavidMunday Excel Worksheet Functions 2 July 1st 05 07:35 AM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 4th 05 10:50 AM


All times are GMT +1. The time now is 11:56 PM.

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"