Array Declaration.

A

apis

Hello everyone,
I was developing one excel programming, i have 100 button in one
sheet. can i used array to assign the button visibility = TRUE using
array ? I am very new to VBA. My last programming language i learn was
C++ and it was 12 years ago..Now i am sort of refreshing everything..

regards,
Aisar Apis
 
J

James Ravenswood

Hello everyone,
     I was developing one excel programming, i have 100 button in one
sheet. can i used array to assign the button visibility = TRUE using
array ? I am very new to VBA. My last programming language i learn was
C++ and it was 12 years ago..Now i am sort of refreshing everything..

regards,
Aisar Apis

Sure. If you put, say, Forms Buttons on a sheet you can treat the as
shapes:

Sub buttonHider()
Dim sh As Shape
For Each sh In ActiveSheet.Shapes
MsgBox sh.Name
Next
ary = Array("Button 1", "Button 2")
n = Application.InputBox(prompt:="enter button index", Type:=1)
Set sh = ActiveSheet.Shapes(n)
sh.Visible = msoFalse

End Sub

use 1 rather than 0 for the first buttton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top