If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > VB Buttons in Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-23-11, 04:34
christyxo christyxo is offline
Registered User
 
Join Date: Oct 2003
Location: London
Posts: 291
Buttons in Excel

Hi,

Does anyone know if it's possible to turn a button placed on sheet1 to visible=False and visible=True.

What I'm trying to do is something along the lines of the below, but I can't find a way in VB to pick up control of the buttons.

Worksheets.("Sheet1").Button("Button1").visible = False

Thanks
Reply With Quote
  #2 (permalink)  
Old 06-23-11, 06:29
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
probably best to ask this in the Excel forum....
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 06-23-11, 08:06
christyxo christyxo is offline
Registered User
 
Join Date: Oct 2003
Location: London
Posts: 291
VB Buttons in Excel

Hi,

Does anyone know if it's possible to turn a button placed on sheet1 to visible=False and visible=True.

What I'm trying to do is something along the lines of the below, but I can't find a way in VB to pick up control of the buttons.

Worksheets.("Sheet1").Button("Button1").visible = False

Thanks
Reply With Quote
  #4 (permalink)  
Old 06-23-11, 11:06
weejas weejas is offline
Registered User
 
Join Date: Sep 2006
Location: Surrey, UK
Posts: 448
What do you want to achieve? The code is correctly formatted, but on its own it will not do anything.
__________________
10% of magic is knowing something that no-one else does. The rest is misdirection.
Reply With Quote
  #5 (permalink)  
Old 06-23-11, 12:00
christyxo christyxo is offline
Registered User
 
Join Date: Oct 2003
Location: London
Posts: 291
I have 3 buttons on an excel page (Sheet1). The buttons are named Button1, Button2, Button3.

My ideal starting point would be to make button2, and button3 invisible from the starting point.

Button1 is a submit button. When pressed I would like the submit button to be hidden, and Button1, and Button2 to become visible.

No matter what I try, I'm just getting messages 'Object doesn't support this property or message".

I actually don't care how it's done - The buttons could be made invisible; greyed out; shrunk in size; not even present to start with and then created as part of the command behind button1...

The long winded solution I have at the moment is to put if commands behind button1 and 2 stating that if the current windows user, is the same user who pressed submit, then do nothing... (There's a hidden audit sheet which tracks who pressed submit).
Reply With Quote
  #6 (permalink)  
Old 06-23-11, 12:18
weejas weejas is offline
Registered User
 
Join Date: Sep 2006
Location: Surrey, UK
Posts: 448
Are you using form buttons or ActiveX buttons? I think that you will only be able to use VBA to control their status with the latter.
__________________
10% of magic is knowing something that no-one else does. The rest is misdirection.
Reply With Quote
  #7 (permalink)  
Old 06-23-11, 19:29
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
The Worksheet class does not have a Button property which is why you get that error. As weejas said, the correct answer depends on what type of buttons they are (ActiveX vs Forms) - but both can be made hidden via VBA. Tell use which type they are and we can show you how to do it!
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #8 (permalink)  
Old 06-23-11, 19:30
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
duplicate thread:
VB Buttons in Excel
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #9 (permalink)  
Old 06-24-11, 03:51
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
threads merged
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #10 (permalink)  
Old 06-24-11, 05:25
christyxo christyxo is offline
Registered User
 
Join Date: Oct 2003
Location: London
Posts: 291
Only duplicate because you asked me to post it in the excel forum, and then moved the 1st one after I posted the 2nd!

Thanks for your help everyone. I'll consider using ActiveX buttons but it might be easier just to put my if condition in the subs. At least I know now that the route I was trying was a dead-end.
Reply With Quote
  #11 (permalink)  
Old 06-24-11, 06:56
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Quote:
Originally Posted by christyxo View Post
At least I know now that the route I was trying was a dead-end.
It wasn't a dead end!

As I said, you can do it with either forms controls or activeX controls: we were just waiting for you to clarify which you are using so we could show you the correct approach.
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #12 (permalink)  
Old 06-24-11, 07:41
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
Quote:
Originally Posted by christyxo View Post
Only duplicate because you asked me to post it in the excel forum, and then moved the 1st one after I posted the 2nd!
not quite true

I made the posting about Excel and moved the thread at the same time.....
but who cares, ultimately you got the answer you needed (I hope)
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #13 (permalink)  
Old 07-18-11, 11:42
christyxo christyxo is offline
Registered User
 
Join Date: Oct 2003
Location: London
Posts: 291
Thanks all; I revisited this and found that it's a lot simpler than expected;

Code:

    ActiveSheet.Shapes("Button 01").Visible = True / False
Reply With Quote
  #14 (permalink)  
Old 07-18-11, 15:14
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
In that case you are using Forms controls.
Code:
ActiveSheet.Buttons("Button 01").Visible = True / False
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On