Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Shapes, Userform and Visible

I have 4 buttons assigned to a userform within a frame. I have four shapes
that are not visible, and want the usere to be able to select a button and
make one of the shapes visible. When I click any of the buttons the shape
becomes visible. But when i select two or more they all become visible.
below is the code for one of the buttons. How do I modify the code to only
allow for one shape to be visible upon slection of the button?

Joel Mills

Sub PLANNEDLegend()
ActiveSheet.Shapes("LEGEND PLANNED").Visible = True
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Shapes, Userform and Visible

You need to set the Visible property of all the other shapes to False.

--

Vasant

"Joel Mills" wrote in message
...
I have 4 buttons assigned to a userform within a frame. I have four

shapes
that are not visible, and want the usere to be able to select a button and
make one of the shapes visible. When I click any of the buttons the shape
becomes visible. But when i select two or more they all become visible.
below is the code for one of the buttons. How do I modify the code to

only
allow for one shape to be visible upon slection of the button?

Joel Mills

Sub PLANNEDLegend()
ActiveSheet.Shapes("LEGEND PLANNED").Visible = True
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Shapes, Userform and Visible

Vasant thanks for your help. Below is the revised code incase others might
find it useful. I followed your advice and set each of the shapes where the
one I want to be visible true and all the others false.

Sub PLANNEDLegend()
ActiveSheet.Shapes("LEGEND PLANNED").Visible = True
ActiveSheet.Shapes("LEGEND PE").Visible = False
ActiveSheet.Shapes("LEGEND ELPE").Visible = False
ActiveSheet.Shapes("LEGEND ELE").Visible = False
End Sub


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
You need to set the Visible property of all the other shapes to False.

--

Vasant

"Joel Mills" wrote in message
...
I have 4 buttons assigned to a userform within a frame. I have four

shapes
that are not visible, and want the usere to be able to select a button
and
make one of the shapes visible. When I click any of the buttons the
shape
becomes visible. But when i select two or more they all become visible.
below is the code for one of the buttons. How do I modify the code to

only
allow for one shape to be visible upon slection of the button?

Joel Mills

Sub PLANNEDLegend()
ActiveSheet.Shapes("LEGEND PLANNED").Visible = True
End Sub






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Shapes, Userform and Visible

You might think it's overkill, but I usually end up with a construct
like below. In the long run I find it's easier to debug and maintain.
It's especially true if you end up with a lot of conditionally visible
or enabled controls.

Const PLANNED_SHAPE As Integer = 1
Const PE_SHAPE As Integer = 2
Const ELPE_SHAPE As Integer = 3
Const ELE_SHAPE As Integer = 4

Sub Button1_Click()
ShowShape(PLANNED_SHAPE)
End Sub

Sub Button2_Click()
ShowShape(PE_SHAPE)
End Sub

Sub Button3_Click()
ShowShape(ELPE_SHAPE)
End Sub

Sub Button4_Click()
ShowShape(ELE_SHAPE)
End Sub

Sub ShowShape(ByVal id as Integer)
ActiveSheet.Shapes("LEGEND PLANNED").Visible = (PLANNED_SHAPE = id)
ActiveSheet.Shapes("LEGEND PE").Visible = (PE_SHAPE = id)
ActiveSheet.Shapes("LEGEND ELPE").Visible = (ELPE_SHAPE = id
ActiveSheet.Shapes("LEGEND ELE").Visible = (ELE_SHAPE = id)
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Shapes, Userform and Visible

Thanks for the reply. I'm trying to teach myself VBA by writing a program
for myself and co-workers use. I appreciate the effort you placed in this
post. I'll try it out, and I am sure, that I can apply it or portions of it
in this project.

Joel Mills


"Nick Hebb" wrote in message
oups.com...
You might think it's overkill, but I usually end up with a construct
like below. In the long run I find it's easier to debug and maintain.
It's especially true if you end up with a lot of conditionally visible
or enabled controls.

Const PLANNED_SHAPE As Integer = 1
Const PE_SHAPE As Integer = 2
Const ELPE_SHAPE As Integer = 3
Const ELE_SHAPE As Integer = 4

Sub Button1_Click()
ShowShape(PLANNED_SHAPE)
End Sub

Sub Button2_Click()
ShowShape(PE_SHAPE)
End Sub

Sub Button3_Click()
ShowShape(ELPE_SHAPE)
End Sub

Sub Button4_Click()
ShowShape(ELE_SHAPE)
End Sub

Sub ShowShape(ByVal id as Integer)
ActiveSheet.Shapes("LEGEND PLANNED").Visible = (PLANNED_SHAPE = id)
ActiveSheet.Shapes("LEGEND PE").Visible = (PE_SHAPE = id)
ActiveSheet.Shapes("LEGEND ELPE").Visible = (ELPE_SHAPE = id
ActiveSheet.Shapes("LEGEND ELE").Visible = (ELE_SHAPE = id)
End Sub



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
Visible Shapes in a frame? Pas Excel Discussion (Misc queries) 4 April 21st 10 08:13 AM
excel document with shapes on it but the shapes do not print [email protected] Excel Worksheet Functions 2 October 22nd 09 06:17 PM
Drawing shapes on Userform mangesh_yadav[_115_] Excel Programming 9 September 16th 04 02:42 PM
UserForm: Jump to the next visible cell Gabor G Excel Programming 2 April 6th 04 02:00 PM
Keep userform visible, but return control to calling routine Ryan Poth[_2_] Excel Programming 0 August 21st 03 05:28 AM


All times are GMT +1. The time now is 04:59 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"